unitee.common
Class LengthBasedOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--unitee.common.LengthBasedOutputStream

public class LengthBasedOutputStream
extends java.io.OutputStream

Forwards data received through OutputStream's or PrintStream's interfaces to the underlaying socket output stream. The print stream adds headers of its own , so the other party can understand when the stream was closed and at the same time not losing any of the properties of streaming data. The data stream looks like this:
NDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
where N is one byte representing the number of bytes of data that follow , and D is the data itself. Basically ,data is read until (N == 0).


Constructor Summary
LengthBasedOutputStream(java.io.OutputStream out)
           
 
Method Summary
 void close()
          Writes a stream terminator and leaves the stream open.
 void write(byte[] bytes, int start, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.OutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LengthBasedOutputStream

public LengthBasedOutputStream(java.io.OutputStream out)
Method Detail

close

public void close()
           throws java.io.IOException
Writes a stream terminator and leaves the stream open.
Overrides:
close in class java.io.OutputStream

write

public void write(int b)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream

write

public void write(byte[] bytes,
                  int start,
                  int len)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream