public class ChannelInputStream extends BufferInputStream implements BinaryInput
Note that it is not safe to use several ChannelInputStreams
over the
same channel (even if synchronized). For file channels, the FileChannelInputStream
can be used if you need this functionality. Use copy-pipes if you need it
on other channel types.
If multiple threads use the same instance of this class, the access to the instance must be synchronized.
ChannelOutputStream
Constructor and Description |
---|
ChannelInputStream(java.nio.channels.ReadableByteChannel readChannel,
int bufferSize,
boolean bufferDirect)
Creates a new instance of BinaryInput.
|
Modifier and Type | Method and Description |
---|---|
protected void |
read(java.nio.ByteBuffer buffer)
Reads some data into the
buffer . |
available, bufferedSize, getPosition, order, order, read, read, read, read, readInput, setPosition, skip
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
readInput, skip
public ChannelInputStream(java.nio.channels.ReadableByteChannel readChannel, int bufferSize, boolean bufferDirect)
readChannel
- the channel used to read databufferSize
- the size of the internal buffer used for flushingbufferDirect
- allocate the internal buffer as direct
protected void read(java.nio.ByteBuffer buffer) throws java.io.EOFException, java.io.IOException
BufferInputStream
buffer
.
This method blocks until at least one byte is read or,
if there are no more data, EOFException
is thrown.read
in class BufferInputStream
buffer
- the buffer into which to read additional datajava.io.EOFException
- if there are no more data availablejava.io.IOException
- if there was an error reading data