public interface RandomAccessRead extends Closeable
| Modifier and Type | Method and Description |
|---|---|
default int |
available()
Returns an estimate of the number of bytes that can be read.
|
RandomAccessReadView |
createView(long startPosition,
long streamLength)
Creates a random access read view starting at the given position with the given length.
|
long |
getPosition()
Returns offset of next byte to be returned by a read method.
|
boolean |
isClosed()
Returns true if this source has been closed.
|
boolean |
isEOF()
A simple test to see if we are at the end of the data.
|
long |
length()
The total number of bytes that are available.
|
default int |
peek()
This will peek at the next byte.
|
int |
read()
Read a single byte of data.
|
default int |
read(byte[] b)
Read a buffer of data.
|
int |
read(byte[] b,
int offset,
int length)
Read a buffer of data.
|
default void |
rewind(int bytes)
Seek backwards the given number of bytes.
|
void |
seek(long position)
Seek to a position in the data.
|
default void |
skip(int length)
Skips a given number of bytes.
|
int read() throws IOException
IOException - If there is an error while reading the data.default int read(byte[] b)
throws IOException
b - The buffer to write the data to.IOException - If there was an error while reading the data.int read(byte[] b,
int offset,
int length)
throws IOException
b - The buffer to write the data to.offset - Offset into the buffer to start writing.length - The amount of data to attempt to read.IOException - If there was an error while reading the data.long getPosition()
throws IOException
read() (if no more bytes are left it
returns a value >= length of source)IOException - If there was an error while getting the current positionvoid seek(long position) throws IOException
position - The position to seek to.IOException - If there is an error while seeking.long length()
throws IOException
IOException - If there is an IO error while determining the length of the data stream.boolean isClosed()
default int peek()
throws IOException
IOException - If there is an error reading the next byte.default void rewind(int bytes)
throws IOException
bytes - the number of bytes to be seeked backwardsIOException - If there is an error while seekingboolean isEOF()
throws IOException
IOException - If there is an error reading the next byte.default int available()
throws IOException
IOException - if this random access has been closeddefault void skip(int length)
throws IOException
length - the number of bytes to be skippedIOException - if an I/O error occurs while reading dataRandomAccessReadView createView(long startPosition, long streamLength) throws IOException
startPosition - start position within the underlying random access readstreamLength - stream lengthIOException - if something went wrong when creating the view for the RandomAccessReadCopyright © 2002–2025 The Apache Software Foundation. All rights reserved.