public class StreamReader extends SequentialReader
Modifier and Type | Field and Description |
---|---|
private long |
_pos |
private java.io.InputStream |
_stream |
Constructor and Description |
---|
StreamReader(java.io.InputStream stream) |
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns an estimate of the number of bytes that can be read (or skipped
over) from this
SequentialReader without blocking by the next
invocation of a method for this input stream. |
byte |
getByte()
Gets the next byte in the sequence.
|
void |
getBytes(byte[] buffer,
int offset,
int count)
Retrieves bytes, writing them into a caller-provided buffer.
|
byte[] |
getBytes(int count)
Returns the required number of bytes from the sequence.
|
long |
getPosition() |
void |
skip(long n)
Skips forward in the sequence.
|
private long |
skipInternal(long n) |
boolean |
trySkip(long n)
Skips forward in the sequence, returning a boolean indicating whether the skip succeeded, or whether the sequence ended.
|
getDouble64, getFloat32, getInt16, getInt32, getInt64, getInt8, getNullTerminatedBytes, getNullTerminatedString, getNullTerminatedStringValue, getS15Fixed16, getString, getString, getString, getStringValue, getUInt16, getUInt32, getUInt8, isMotorolaByteOrder, setMotorolaByteOrder
public long getPosition()
getPosition
in class SequentialReader
public byte getByte() throws java.io.IOException
SequentialReader
getByte
in class SequentialReader
java.io.IOException
public byte[] getBytes(int count) throws java.io.IOException
SequentialReader
getBytes
in class SequentialReader
count
- The number of bytes to be returnedjava.io.IOException
public void getBytes(byte[] buffer, int offset, int count) throws java.io.IOException
SequentialReader
getBytes
in class SequentialReader
buffer
- The array to write bytes to.offset
- The starting position within buffer to write to.count
- The number of bytes to be written.java.io.IOException
public void skip(long n) throws java.io.IOException
SequentialReader
EOFException
is thrown.skip
in class SequentialReader
n
- the number of byte to skip. Must be zero or greater.java.io.EOFException
- the end of the sequence is reached.java.io.IOException
- an error occurred reading from the underlying source.public boolean trySkip(long n) throws java.io.IOException
SequentialReader
trySkip
in class SequentialReader
n
- the number of byte to skip. Must be zero or greater.java.io.IOException
- an error occurred reading from the underlying source.public int available()
SequentialReader
SequentialReader
without blocking by the next
invocation of a method for this input stream. A single read or skip of
this many bytes will not block, but may read or skip fewer bytes.
Note that while some implementations of SequentialReader
like
SequentialByteArrayReader
will return the total remaining number
of bytes in the stream, others will not. It is never correct to use the
return value of this method to allocate a buffer intended to hold all
data in this stream.
available
in class SequentialReader
SequentialReader
without blocking or
0
when it reaches the end of the input stream.private long skipInternal(long n) throws java.io.IOException
java.io.IOException