public interface RandomAccessRead extends Closeable
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns an estimate of the number of bytes that can be read.
|
long |
getPosition()
Returns offset of next byte to be returned by a read method.
|
boolean |
isClosed()
Returns true if this stream 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.
|
int |
peek()
This will peek at the next byte.
|
int |
read()
Read a single byte of data.
|
int |
read(byte[] b)
Read a buffer of data.
|
int |
read(byte[] b,
int offset,
int length)
Read a buffer of data.
|
byte[] |
readFully(int length)
Reads a given number of bytes.
|
void |
rewind(int bytes)
Seek backwards the given number of bytes.
|
void |
seek(long position)
Seek to a position in the data.
|
int read() throws IOException
IOException
- If there is an error while reading the data.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
void 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()
int peek() throws IOException
IOException
- If there is an error reading the next byte.void rewind(int bytes) throws IOException
bytes
- the number of bytes to be seeked backwardsIOException
- If there is an error while seekingbyte[] readFully(int length) throws IOException
length
- the number of bytes to be readIOException
- if an I/O error occurs while reading databoolean isEOF() throws IOException
IOException
- If there is an error reading the next byte.int available() throws IOException
IOException
- if this random access has been closedCopyright © 2002–2017 The Apache Software Foundation. All rights reserved.