|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
com.claritysys.io.MessageOutputStream
public final class MessageOutputStream
A buffered output stream for encoding 2-byte-header message packets. Data is buffered internally in a byte array until the send () method is invoked. The data is then flushed to the underlying OutputStream with a 2 byte header with the message length in network byte order.
The internal buffer will grow to accomodate however much data is written to it.
| Field Summary | |
|---|---|
protected byte[] |
buffer
The underlying buffer. |
protected int |
dataLength
The length of data in the write buffer. |
| Fields inherited from class java.io.FilterOutputStream |
|---|
out |
| Constructor Summary | |
|---|---|
MessageOutputStream(java.io.OutputStream out)
Construct a message stream on the given output stream. |
|
| Method Summary | |
|---|---|
void |
flush()
Send the message content on the underlying OutputStream. |
void |
write(byte[] b)
Write the entire array b[] to the internal buffer. |
void |
write(byte[] b,
int off,
int len)
Write an array of bytes to the internal buffer starting from off, length len. |
void |
write(int b)
Write a single byte to the internal buffer. |
| Methods inherited from class java.io.FilterOutputStream |
|---|
close |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected byte[] buffer
protected int dataLength
| Constructor Detail |
|---|
public MessageOutputStream(java.io.OutputStream out)
out - The underlying OutputStream to write to.| Method Detail |
|---|
public void write(int b)
write in class java.io.FilterOutputStreamb - A byte to write.public void write(byte[] b)
write in class java.io.FilterOutputStreamb -
public void write(byte[] b,
int off,
int len)
write in class java.io.FilterOutputStreamb - off - len -
public void flush()
throws java.io.IOException
The data is sent with a 2 byte length header, high byte first. This is done with one write/flush to the underlying stream.
flush in interface java.io.Flushableflush in class java.io.FilterOutputStreamjava.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||