org.entityfs.support.io
Class ReadableByteBufferChannel
java.lang.Object
org.entityfs.support.io.ReadableByteBufferChannel
- All Implemented Interfaces:
- Closeable, Channel, ReadableByteChannel
public class ReadableByteBufferChannel
- extends Object
- implements ReadableByteChannel
This is a ReadableByteChannel
that uses a ByteBuffer
to read
data from. It assumes exclusive access to the ByteBuffer
.
Read operations will update the ByteBuffer
's internal position.
- Since:
- 1.0
- Author:
- Karl Gustafsson
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_TEMP_BUFFER_SIZE
public static final int DEFAULT_TEMP_BUFFER_SIZE
- See Also:
- Constant Field Values
ReadableByteBufferChannel
public ReadableByteBufferChannel(ByteBuffer buffer,
int tempBufferSize)
throws IllegalArgumentException
- Create a new
ReadableByteBufferChannel
.
- Parameters:
buffer
- The buffer to read data from.tempBufferSize
- The size, in bytes, of the temporary buffer used
when reading data from the buffer. It must be >= 1
byte.
- Throws:
IllegalArgumentException
- If the temporary buffer size is invalid.
ReadableByteBufferChannel
public ReadableByteBufferChannel(ByteBuffer buffer)
- Create a new
ReadableByteBufferChannel
. The default size,
8192 bytes, will be used for the temporary
buffer used when reading data.
- Parameters:
buffer
- The buffer to read data from.
read
public int read(ByteBuffer target)
throws IOException
- Specified by:
read
in interface ReadableByteChannel
- Throws:
IOException
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interface Channel
close
public void close()
- Specified by:
close
in interface Closeable
- Specified by:
close
in interface Channel