public class ByteBuffer_InputStream extends InputStream
This class is thread safe: Methods that might modify the backing ByteBuffer are synchronized on the ByteBuffer.
ByteBuffer
,
InputStream
Modifier and Type | Field and Description |
---|---|
static String |
ID
Class identification name with source code version and date.
|
Constructor and Description |
---|
ByteBuffer_InputStream(ByteBuffer source)
Construct a ByteBuffer_InputStream on a ByteBuffer.
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Get the number of bytes remaining in the source.
|
void |
mark(int read_limit)
Sets a mark at the current input position.
|
boolean |
markSupported()
|
int |
read()
Get the next datum from the source.
|
int |
read(byte[] byte_array)
Get some number of bytes from the source and store them into a
byte array.
|
int |
read(byte[] byte_array,
int offset,
int length)
Get some number of bytes from the source and store them into a
byte array.
|
void |
reset()
|
long |
skip(long amount)
Skip over some number of input bytes.
|
ByteBuffer |
Source()
Get the ByteBuffer backing this ByteBuffer_InputStream.
|
close
public static final String ID
public ByteBuffer_InputStream(ByteBuffer source)
source
- The ByteBuffer to be used as the source of input data.public ByteBuffer Source()
public int available()
public void mark(int read_limit)
The operation is synchronized on the source buffer.
mark
in class InputStream
read_limit
- Ignored: The read limit is always the
source
limit.public boolean markSupported()
markSupported
in class InputStream
public int read()
The operation is synchronized on the source buffer.
read
in class InputStream
source
byte (0-255) at
the current buffer position, or -1 if the source
position is at its limit
.public int read(byte[] byte_array)
This method simply returns
read (byte_array, 0, byte_array.length)
.
read
in class InputStream
byte_array
- A byte[] array where the source data is to be
stored.source
position is at its limit
.NullPointerException
- If the byte array is null.read(byte[], int, int)
public int read(byte[] byte_array, int offset, int length)
If the length to read is less than or equal to zero, zero is
returned. Otherwise the effective length is the lesser of the
length and the amount of data remaining
in the source
buffer.
The operation is synchronized on the source buffer.
read
in class InputStream
byte_array
- A byte[] array where the source data is to be
stored.offset
- The index of the array where the first byte will be
stored.length
- The maximum number of bytes to transfer from the
source
to the array.source
position is at its limit
.NullPointerException
- If the byte array is null.IndexOutOfBoundsException
- If the offset is negative or
the offset plus the effective length is greater than the
remaining space in the array.public void reset() throws IOException
source
position to the most recent
mark
position.
The operation is synchronized on the source buffer.
reset
in class InputStream
IOException
- If no mark has been set.public long skip(long amount)
The source
input position is moved to its
current position plus the lesser of the amount specified or
the amount available data remaining
in the buffer.
The operation is synchronized on the source buffer.
skip
in class InputStream
amount
- The amount of data to skip.