public class EXRFileInputStream extends Object implements EXRInputStream, AutoCloseable
EXRInputStream
from a
file. This class acquires a shared lock on the file and implements
AutoCloseable
so that it may be used in try
-with-resources.Constructor and Description |
---|
EXRFileInputStream(Path path) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
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 EXRFileInputStream(Path path) throws EXRIOException
EXRIOException
public void close() throws EXRIOException
close
in interface AutoCloseable
EXRIOException
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.