public abstract class DelegatingSeekableInputStream extends SeekableInputStream
SeekableInputStream for generic input streams.
Implementations must implement getPos() and seek(long) and may optionally
implement other read methods to improve performance.
| Constructor and Description |
|---|
DelegatingSeekableInputStream(InputStream stream) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
abstract long |
getPos()
Return the current position in the InputStream.
|
InputStream |
getStream() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
int |
read(ByteBuffer buf)
Read
buf.remaining() bytes of data into a ByteBuffer. |
void |
readFully(byte[] bytes)
Read a byte array of data, from position 0 to the end of the array.
|
void |
readFully(byte[] bytes,
int start,
int len)
Read
len bytes of data into an array, at position start. |
void |
readFully(ByteBuffer buf)
Read
buf.remaining() bytes of data into a ByteBuffer. |
abstract void |
seek(long newPos)
Seek to a new position in the InputStream.
|
available, mark, markSupported, read, reset, skippublic DelegatingSeekableInputStream(InputStream stream)
public InputStream getStream()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic abstract long getPos()
throws IOException
SeekableInputStreamgetPos in class SeekableInputStreamIOException - If the underlying stream throws IOExceptionpublic abstract void seek(long newPos)
throws IOException
SeekableInputStreamseek in class SeekableInputStreamnewPos - the new position to seek toIOException - If the underlying stream throws IOExceptionpublic int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic void readFully(byte[] bytes)
throws IOException
SeekableInputStream
This method is equivalent to read(bytes, 0, bytes.length).
This method will block until len bytes are available to copy into the
array, or will throw EOFException if the stream ends before the
array is full.
readFully in class SeekableInputStreambytes - a byte array to fill with data from the streamIOException - If the underlying stream throws IOExceptionEOFException - If the stream has fewer bytes left than are needed to
fill the array, bytes.lengthpublic void readFully(byte[] bytes,
int start,
int len)
throws IOException
SeekableInputStreamlen bytes of data into an array, at position start.
This method will block until len bytes are available to copy into the
array, or will throw EOFException if the stream ends before the
array is full.
readFully in class SeekableInputStreambytes - a byte array to fill with data from the streamstart - the starting position in the byte array for datalen - the length of bytes to read into the byte arrayIOException - If the underlying stream throws IOExceptionEOFException - If the stream has fewer than len bytes leftpublic int read(ByteBuffer buf) throws IOException
SeekableInputStreambuf.remaining() bytes of data into a ByteBuffer.
This method will copy available bytes into the buffer, reading at most
buf.remaining() bytes. The number of bytes actually copied is
returned by the method, or -1 is returned to signal that the end of the
underlying stream has been reached.
read in class SeekableInputStreambuf - a byte buffer to fill with data from the streamIOException - If the underlying stream throws IOExceptionpublic void readFully(ByteBuffer buf) throws IOException
SeekableInputStreambuf.remaining() bytes of data into a ByteBuffer.
This method will block until buf.remaining() bytes are available
to copy into the buffer, or will throw EOFException if the stream
ends before the buffer is full.
readFully in class SeekableInputStreambuf - a byte buffer to fill with data from the streamIOException - If the underlying stream throws IOExceptionEOFException - If the stream has fewer bytes left than are needed to
fill the buffer, buf.remaining()Copyright © 2018 The Apache Software Foundation. All rights reserved.