private static class ReceivingThread.FreeColNetworkInputStream
extends java.io.InputStream
END_OF_STREAM
is encountered. In
order to continue receiving data, the method enable()
has to be called. Calls to close()
have no effect,
the underlying input stream has to be closed directly.Modifier and Type | Field and Description |
---|---|
private int |
bEnd |
private int |
bStart |
private byte[] |
buffer |
private static int |
BUFFER_SIZE |
private boolean |
empty |
private static char |
END_OF_STREAM |
private java.io.InputStream |
in |
private boolean |
wait |
Constructor and Description |
---|
FreeColNetworkInputStream(java.io.InputStream in)
Creates a new
FreeColNetworkInputStream . |
Modifier and Type | Method and Description |
---|---|
void |
enable()
Prepares the input stream for a new message.
|
private boolean |
fill()
Fills the buffer with data.
|
int |
read()
Reads a single byte.
|
int |
read(byte[] b,
int off,
int len)
Reads from the buffer and returns the data.
|
private static final int BUFFER_SIZE
private static final char END_OF_STREAM
private final java.io.InputStream in
private final byte[] buffer
private int bStart
private int bEnd
private boolean empty
private boolean wait
public FreeColNetworkInputStream(java.io.InputStream in)
FreeColNetworkInputStream
.in
- The input stream in which this object should get the data
from.public void enable()
read
return the data
instead of -1
.private boolean fill() throws java.io.IOException
java.io.IOException
- is thrown by the underlying read.java.lang.IllegalStateException
- if the buffer is not empty.public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
- is thrown by the underlying read.read(byte[], int, int)
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
b
- The buffer to put the data in.off
- The offset to use when writing the data.len
- The maximum number of bytes to read.END_OF_STREAM
was encountered).java.io.IOException