java.io.Closeable
, java.lang.AutoCloseable
, RandomAccess
, RandomAccessRead
, SequentialRead
public class RandomAccessBuffer extends java.lang.Object implements RandomAccess, java.io.Closeable
Constructor | Description |
---|---|
RandomAccessBuffer() |
Default constructor.
|
Modifier and Type | Method | Description |
---|---|---|
RandomAccessBuffer |
clone() |
|
void |
close() |
Release resources that are being held.
|
long |
getPosition() |
Returns offset of next byte to be returned by a read method.
|
long |
length() |
The total number of bytes that are available.
|
int |
read() |
Read a single byte of data.
|
int |
read(byte[] b,
int offset,
int length) |
Read a buffer of data.
|
void |
seek(long position) |
Seek to a position in the data.
|
void |
write(byte[] b,
int offset,
int length) |
Write a buffer of data to the stream.
|
void |
write(int b) |
Write a byte to the stream.
|
public RandomAccessBuffer clone()
clone
in class java.lang.Object
public void close() throws java.io.IOException
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
close
in interface SequentialRead
java.io.IOException
- If there is an error closing this resource.public void seek(long position) throws java.io.IOException
seek
in interface RandomAccessRead
position
- The position to seek to.java.io.IOException
- If there is an error while seeking.public long getPosition() throws java.io.IOException
getPosition
in interface RandomAccessRead
SequentialRead.read()
(if no more bytes are left it returns a value >= length of source)java.io.IOException
public int read() throws java.io.IOException
read
in interface SequentialRead
java.io.IOException
- If there is an error while reading the data.public int read(byte[] b, int offset, int length) throws java.io.IOException
read
in interface SequentialRead
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.java.io.IOException
- If there was an error while reading the data.public long length() throws java.io.IOException
length
in interface RandomAccessRead
java.io.IOException
- If there is an IO error while determining the
length of the data stream.public void write(int b) throws java.io.IOException
write
in interface RandomAccess
b
- The byte to write.java.io.IOException
- If there is an IO error while writing.public void write(byte[] b, int offset, int length) throws java.io.IOException
write
in interface RandomAccess
b
- The buffer to get the data from.offset
- An offset into the buffer to get the data from.length
- The length of data to write.java.io.IOException
- If there is an error while writing the data.