public final class MessageInputStream
extends java.io.FilterInputStream
Modifier and Type | Field and Description |
---|---|
protected boolean |
atEOF
A flag to remember that we've already hit EOF.
|
protected byte[] |
buffer
The buffer in which message bytes are queued up for reading.
|
protected int |
dataLength
The current length of data in the buffer.
|
Constructor and Description |
---|
MessageInputStream(java.io.InputStream in)
Create a new MessageInputStream on the given InputStream.
|
Modifier and Type | Method and Description |
---|---|
int |
read(byte[] b)
Read an array full of bytes from this stream.
|
int |
read(byte[] b,
int off,
int len)
Read an array full of bytes from this stream.
|
java.lang.String |
readString()
Read a String from the underlying stream.
|
int |
receive()
Wait for an incoming message from the InputStream.
|
protected byte[] buffer
protected int dataLength
protected boolean atEOF
public MessageInputStream(java.io.InputStream in)
in
- The underlying InputStream to read from.public int read(byte[] b) throws java.io.IOException
Be sure that the array is larger than any potential message.
read
in class java.io.FilterInputStream
b
- A byte array to read data into.java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
Be sure that the array is larger than any potential message.
read
in class java.io.FilterInputStream
b
- A byte array to read data into.off
- The starting position to read into.len
- The maximum number of bytes to read.java.io.IOException
public java.lang.String readString() throws java.io.IOException
If data has been read from this stream already this will return the remaining data. If there is no data available, this will block until a message is received.
java.io.IOException
String.String(byte[],int,int)
public int receive() throws java.io.IOException
java.io.IOException
Copyright ? 2002 Clarity Systems Group, LLC. All Rights Reserved.