wt.util
Class BlockDataInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
wt.util.BlockDataInputStream
- public class BlockDataInputStream
- extends FilterInputStream
An input stream filter used to read a stream nested on another stream by
the BlockDataOutputStream
class.
The filter will return EOF at the end of the nested stream without reading past the
end of the nested stream.
For best read through performance when layered over buffered streams, the read length
should be 4 bytes larger than the blocks that were written to allow read ahead of the
next block header.
Reads may block until a data block is fully read as long as read buffers are large enough
to receive the entire block. Multiple blocks may be read at once if block headers are
received while reading. If a full block has been read but the next block header was not
received, the current data is returned without further blocking. The result is that the
number of bytes read at once should always meet or exceed the number of bytes that were
written in a block if the read buffer is large enough.
Method Summary |
int |
available()
Return how many bytes remain in the current block. |
boolean |
markSupported()
Returns false. |
private void |
nextBlock()
|
int |
read()
|
int |
read(byte[] buf,
int off,
int len)
|
private int |
readFully(byte[] buf,
int off,
int min_len,
int max_len)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
remaining
private int remaining
eof
private boolean eof
header
private byte[] header
unused
private int unused
offset
private int offset
DEBUG
private static final boolean DEBUG
- See Also:
- Constant Field Values
BlockDataInputStream
public BlockDataInputStream(InputStream input_stream)
read
public int read()
throws IOException
- Throws:
IOException
read
public int read(byte[] buf,
int off,
int len)
throws IOException
- Throws:
IOException
readFully
private int readFully(byte[] buf,
int off,
int min_len,
int max_len)
throws IOException
- Throws:
IOException
nextBlock
private void nextBlock()
throws IOException
- Throws:
IOException
available
public int available()
throws IOException
- Return how many bytes remain in the current block.
This does not necessarily imply that reads will not block
while reading the remainder of the block, but it indicates that
the data has been sent.
- Throws:
IOException
markSupported
public boolean markSupported()
- Returns false.