messif.objects.nio
Class ChannelInputStream
java.lang.Object
java.io.InputStream
messif.objects.nio.BufferInputStream
messif.objects.nio.ChannelInputStream
- All Implemented Interfaces:
- java.io.Closeable, BinaryInput
- Direct Known Subclasses:
- FileChannelInputStream
public class ChannelInputStream
- extends BufferInputStream
- implements BinaryInput
Buffered binary input stream.
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.
- See Also:
ChannelOutputStream
Constructor Summary |
ChannelInputStream(java.nio.channels.ReadableByteChannel readChannel,
int bufferSize,
boolean bufferDirect)
Creates a new instance of BinaryInput. |
Method Summary |
protected void |
read(java.nio.ByteBuffer buffer)
Reads some data into the buffer . |
Methods inherited from class java.io.InputStream |
close, mark, markSupported, read, reset |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ChannelInputStream
public ChannelInputStream(java.nio.channels.ReadableByteChannel readChannel,
int bufferSize,
boolean bufferDirect)
- Creates a new instance of BinaryInput.
- Parameters:
readChannel
- the channel used to read databufferSize
- the size of the internal buffer used for flushingbufferDirect
- allocate the internal buffer as direct
read
protected void read(java.nio.ByteBuffer buffer)
throws java.io.EOFException,
java.io.IOException
- Description copied from class:
BufferInputStream
- Reads some data into the
buffer
.
This method blocks until at least one byte is read or,
if there are no more data, EOFException
is thrown.
- Overrides:
read
in class BufferInputStream
- Parameters:
buffer
- the buffer into which to read additional data
- Throws:
java.io.EOFException
- if there are no more data available
java.io.IOException
- if there was an error reading data