public class ByteChannelInputStream extends Object implements EXRInputStream
SeekableByteChannel
.
This class assumes that the SeekableByteChannel
specified during
its construction will remain open through the lifetime of an instance.
Constructor and Description |
---|
ByteChannelInputStream(SeekableByteChannel channel)
Constructs a
ByteChannelInputStream which relies on a non-null,
already open SeekableByteChannel . |
Modifier and Type | Method and Description |
---|---|
long |
position()
Get the current reading position, in bytes from the beginning of the
stream.
|
void |
position(long pos)
Set the current position.
|
boolean |
read(ByteBuffer dst)
Read from the stream.
|
public ByteChannelInputStream(SeekableByteChannel channel)
ByteChannelInputStream
which relies on a non-null,
already open SeekableByteChannel
.channel
- the SeekableByteChannel
to be used by the
newly constructed instanceNullPointerException
- is channel
is nullIllegalArgumentException
- is channel
is not openpublic boolean read(ByteBuffer dst) throws EXRIOException
EXRInputStream
read(dst)
reads n bytes from the stream, where
n is the number of bytes remaining in the buffer, that is,
dst.remaining()
, at the moment this method is invoked. The bytes
are read into the current position of the buffer.
If the stream contains less than n bytes, or if an I/O error
occurs, read(dst)
throws an exception. If read(dst)
reads the last byte from the stream it returns false
, otherwise
it returns true
.
read
in interface EXRInputStream
dst
- The buffer into which bytes are to be transferredfalse
if the call read the last byte from the stream,
true
otherwise.EXRIOException
- if the stream contains less than n
bytes, or if an I/O error occurs.public long position() throws EXRIOException
EXRInputStream
read()
will read the first byte in
the stream file, position()
returns 0.position
in interface EXRInputStream
EXRIOException
- if an I/O error occurs.public void position(long pos) throws EXRIOException
EXRInputStream
position(i)
,
position()
returns i.position
in interface EXRInputStream
pos
- the new reading position.EXRIOException
- if an I/O error occurs.