public class ByteArrayReader extends RandomAccessReader
By default, the reader operates with Motorola byte order (big endianness). This can be changed by calling
setMotorolaByteOrder(boolean)
.
Constructor and Description |
---|
ByteArrayReader(byte[] buffer) |
Modifier and Type | Method and Description |
---|---|
byte[] |
getBytes(int index,
int count)
Returns the required number of bytes from the specified index from the underlying source.
|
long |
getLength()
Returns the length of the data source in bytes.
|
getBit, getDouble64, getFloat32, getInt16, getInt24, getInt32, getInt64, getInt8, getNullTerminatedString, getS15Fixed16, getString, getString, getUInt16, getUInt32, getUInt8, isMotorolaByteOrder, setMotorolaByteOrder
public long getLength()
RandomAccessReader
This is a simple operation for implementations (such as RandomAccessFileReader
and
ByteArrayReader
) that have the entire data source available.
Users of this method must be aware that sequentially accessed implementations such as
RandomAccessStreamReader
will have to read and buffer the entire data source in
order to determine the length.
getLength
in class RandomAccessReader
public byte[] getBytes(int index, int count) throws IOException
RandomAccessReader
getBytes
in class RandomAccessReader
index
- The index from which the bytes begins in the underlying sourcecount
- The number of bytes to be returnedBufferBoundsException
- if the requested bytes extend beyond the end of the underlying data sourceIOException
- if the byte is unable to be readCopyright © 2002-2015 Drew Noakes. All Rights Reserved.