public class ByteBufferInputStream extends Object implements EXRInputStream
Constructor and Description |
---|
ByteBufferInputStream(ByteBuffer buffer)
Creates a new
ByteBufferInputStream by wrapping the input
non null buffer. |
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 ByteBufferInputStream(ByteBuffer buffer)
ByteBufferInputStream
by wrapping the input
non null buffer.
The position
methods of this stream are relative to the
initial value of buffer.position()
.
buffer
- the source byte bufferIllegalArgumentException
- if buffer
is null
.public 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.