Class BinaryReader
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Reads and returns an object from the current position in the specified input stream.static interface
Reads and returns an object from the current position in the specified BinaryReader. -
Field Summary
Modifier and TypeFieldDescriptionprotected DataConverter
protected long
protected final ByteProvider
static final int
The size of a BYTE in Java.static final int
The size of an INTEGER in Java.static final int
The size of a LONG in Java.static final int
The size of a SHORT in Java. -
Constructor Summary
ConstructorDescriptionBinaryReader
(ByteProvider provider, boolean isLittleEndian) Constructs a reader using the given ByteProvider and endian-order.BinaryReader
(ByteProvider provider, DataConverter converter, long initialIndex) Creates a BinaryReader instance. -
Method Summary
Modifier and TypeMethodDescriptionint
align
(int alignValue) Advances the current index so that it aligns to the specified value (if not already aligned).Returns a BinaryReader that is in BigEndian mode.Returns a BinaryReader that is in LittleEndian mode.clone()
Returns an independent clone of this reader positioned at the same index.clone
(long newIndex) Returns a clone of this reader, with its own independent current position, positioned at the new index.Returns the underlying byte provider.Returns an InputStream that is a live view of the BinaryReader's position.long
Returns the current index value.boolean
hasNext()
Returns true if this stream has data that could be read at the current position.boolean
hasNext
(int count) Returns true if this stream has data that could be read at the current position.boolean
Returns true if this reader will extract values in big endian.boolean
Returns true if this reader will extract values in little endian, otherwise in big endian.boolean
isValidIndex
(int index) Returns true if the specified unsigned int32 index into the underlying byte provider is valid.boolean
isValidIndex
(long index) Returns true if the specified index into the underlying byte provider is valid.boolean
isValidRange
(long startIndex, int count) Returns true if the specified range is valid and does not wrap around the end of the index space.long
length()
Returns the length of the underlying file.byte
Peeks at the next byte without incrementing the current index.int
Peeks at the next integer without incrementing the current index.long
Peeks at the next long without incrementing the current index.short
Peeks at the next short without incrementing the current index.readAsciiString
(long index) Reads a null terminated US-ASCII string, starting at specified index, stopping at the first null character.readAsciiString
(long index, int length) Reads an fixed length US-ASCII string starting atindex
.byte
readByte
(long index) Returns the signed BYTE atindex
.byte[]
readByteArray
(long index, int nElements) Returns the BYTE array ofnElements
starting atindex
.int
readInt
(long index) Returns the signed INTEGER atindex
.int
readInt
(DataConverter dc, long index) Returns the signed INTEGER atindex
.int[]
readIntArray
(long index, int nElements) Returns the INTEGER array ofnElements
starting atindex
.long
readLong
(long index) Returns the signed LONG atindex
.long
readLong
(DataConverter dc, long index) Returns the signed LONG atindex
.long[]
readLongArray
(long index, int nElements) Returns the LONG array ofnElements
starting atindex
.<T> T
Reads an object from the current position, using the supplied reader function.<T> T
readNext
(BinaryReader.ReaderFunction<T> func) Reads an object from the current position, using the supplied reader function.Reads a null terminated US-ASCII string starting at the current index, advancing the current index by the length of the string that was found.readNextAsciiString
(int length) Reads a fixed length US-ASCII string starting at the current index, advancing the current index by the specified fixed length.byte
Reads the byte at the current index and then increments the current index bySIZEOF_BYTE
.byte[]
readNextByteArray
(int nElements) Reads a byte array ofnElements
starting at the current index and then increments the current index bySIZEOF_BYTE * nElements
.int
Reads the integer at the current index and then increments the current index bySIZEOF_INT
.int
Reads the integer at the current index and then increments the current index bySIZEOF_INT
.int[]
readNextIntArray
(int nElements) Reads an integer array ofnElements
starting at the current index and then increments the current index bySIZEOF_INT * nElements
.long
Reads the long at the current index and then increments the current index bySIZEOF_LONG
.long
Reads the long at the current index and then increments the current index bySIZEOF_LONG
.long[]
readNextLongArray
(int nElements) Reads a long array ofnElements
starting at the current index and then increments the current index bySIZEOF_LONG * nElements
.short
Reads the short at the current index and then increments the current index bySIZEOF_SHORT
.short
Reads the short at the current index and then increments the current index bySIZEOF_SHORT
.short[]
readNextShortArray
(int nElements) Reads a short array ofnElements
starting at the current index and then increments the current index bySIZEOF_SHORT * nElements
.Reads a null-terminated UTF-16 Unicode string at the current index, advancing the current index by the length of the string that was found.readNextUnicodeString
(int charCount) Reads a fixed length UTF-16 Unicode string at the current index, advancing the current index by the length of the string that was found.int
Reads the unsigned byte at the current index and then increments the current index bySIZEOF_BYTE
.long
Reads the unsigned integer at the current index and then increments the current index bySIZEOF_INT
.long
Reads the unsigned integer at the current index and then increments the current index bySIZEOF_INT
.int
Reads an unsigned int32 value, and returns it as a java int (instead of a java long).int
Reads an unsigned int32 value, and returns it as a java int (instead of a java long).int
Reads the unsigned short at the current index and then increments the current index bySIZEOF_SHORT
.int
Reads the unsigned short at the current index and then increments the current index bySIZEOF_SHORT
.long
readNextUnsignedValue
(int len) Returns the unsigned value of the integer (of the specified length) at the current index.long
readNextUnsignedValue
(DataConverter dc, int len) Returns the unsigned value of the integer (of the specified length) at the current index.int
Reads a variable length / unknown format unsigned integer from the current position, using the supplied reader function, returning it (if it fits) as a 32 bit java integer.int
Reads a variable length / unknown format unsigned integer from the current position, using the supplied reader function, returning it (if it fits) as a 32 bit java integer.Reads a null-terminated UTF-8 string at the current index, advancing the current index by the length of the string that was found.readNextUtf8String
(int length) Reads a fixed length UTF-8 string the current index, advancing the current index by the length of the string that was found.long
readNextValue
(int len) Returns the signed value of the integer (of the specified length) at the current index.long
readNextValue
(DataConverter dc, int len) Returns the signed value of the integer (of the specified length) at the current index.int
Reads a variable length / unknown format integer from the current position, using the supplied reader function, returning it (if it fits) as a 32 bit java integer.int
Reads a variable length / unknown format integer from the current position, using the supplied reader function, returning it (if it fits) as a 32 bit java integer.short
readShort
(long index) Returns the signed SHORT atindex
.short
readShort
(DataConverter dc, long index) Returns the signed SHORT atindex
.short[]
readShortArray
(long index, int nElements) Returns the SHORT array ofnElements
starting atindex
.readUnicodeString
(long index) Reads a null-terminated UTF-16 Unicode string starting atindex
and using the pre-specifiedendianness
.readUnicodeString
(long index, int charCount) Reads a fixed length UTF-16 Unicode string oflength
characters starting atindex
, using the pre-specifiedendianness
.int
readUnsignedByte
(long index) Returns the unsigned BYTE atindex
.long
readUnsignedInt
(long index) Returns the unsigned INTEGER atindex
.long
readUnsignedInt
(DataConverter dc, long index) Returns the unsigned INTEGER atindex
.int
readUnsignedShort
(long index) Returns the unsigned SHORT atindex
.int
readUnsignedShort
(DataConverter dc, long index) Returns the unsigned SHORT atindex
.long
readUnsignedValue
(long index, int len) Returns the unsigned value of the integer (of the specified length) at the specified offset.long
readUnsignedValue
(DataConverter dc, long index, int len) Returns the unsigned value of the integer (of the specified length) at the specified offset.readUtf8String
(long index) Reads a null-terminated UTF-8 string starting atindex
.readUtf8String
(long index, int length) Reads a fixed length UTF-8 string oflength
bytes starting atindex
.long
readValue
(long index, int len) Returns the signed value of the integer (of the specified length) at the specified offset.long
readValue
(DataConverter dc, long index, int len) Returns the signed value of the integer (of the specified length) at the specified offset.void
setLittleEndian
(boolean isLittleEndian) Sets the endian of this binary reader.long
setPointerIndex
(int index) A convenience method for setting the index using a 32 bit integer.long
setPointerIndex
(long index) Sets the current index to the specified value.
-
Field Details
-
SIZEOF_BYTE
public static final int SIZEOF_BYTEThe size of a BYTE in Java.- See Also:
-
SIZEOF_SHORT
public static final int SIZEOF_SHORTThe size of a SHORT in Java.- See Also:
-
SIZEOF_INT
public static final int SIZEOF_INTThe size of an INTEGER in Java.- See Also:
-
SIZEOF_LONG
public static final int SIZEOF_LONGThe size of a LONG in Java.- See Also:
-
provider
-
converter
-
currentIndex
protected long currentIndex
-
-
Constructor Details
-
BinaryReader
Constructs a reader using the given ByteProvider and endian-order. If isLittleEndian is true, then all values read from the file will be done so assuming little-endian order. Otherwise, if isLittleEndian is false, then all values will be read assuming big-endian order.- Parameters:
provider
- the byte providerisLittleEndian
- the endian-order
-
BinaryReader
Creates a BinaryReader instance.- Parameters:
provider
- the ByteProvider to useconverter
- theDataConverter
to useinitialIndex
- the initial offset
-
-
Method Details
-
clone
Returns a clone of this reader, with its own independent current position, positioned at the new index.- Parameters:
newIndex
- the new index- Returns:
- an independent clone of this reader positioned at the new index
-
clone
Returns an independent clone of this reader positioned at the same index. -
asBigEndian
Returns a BinaryReader that is in BigEndian mode.- Returns:
- a new independent BinaryReader, at the same position, in BigEndian mode
-
asLittleEndian
Returns a BinaryReader that is in LittleEndian mode.- Returns:
- a new independent instance, at the same position, in LittleEndian mode
-
isLittleEndian
public boolean isLittleEndian()Returns true if this reader will extract values in little endian, otherwise in big endian.- Returns:
- true is little endian, false is big endian
-
isBigEndian
public boolean isBigEndian()Returns true if this reader will extract values in big endian.- Returns:
- true is big endian, false is little endian
-
setLittleEndian
public void setLittleEndian(boolean isLittleEndian) Sets the endian of this binary reader.- Parameters:
isLittleEndian
- true for little-endian and false for big-endian
-
length
Returns the length of the underlying file.- Returns:
- returns the length of the underlying file
- Throws:
IOException
- if an I/O error occurs
-
isValidIndex
public boolean isValidIndex(int index) Returns true if the specified unsigned int32 index into the underlying byte provider is valid.- Parameters:
index
- an integer that is treated as an unsigned int32 index into the byte provider- Returns:
- returns true if the specified index is valid
-
isValidIndex
public boolean isValidIndex(long index) Returns true if the specified index into the underlying byte provider is valid.- Parameters:
index
- the index in the byte provider- Returns:
- returns true if the specified index is valid
-
isValidRange
public boolean isValidRange(long startIndex, int count) Returns true if the specified range is valid and does not wrap around the end of the index space.- Parameters:
startIndex
- the starting index to check, treated as an unsigned int64count
- the number of bytes to check- Returns:
- boolean true if all bytes between startIndex to startIndex+count (exclusive) are valid (according to the underlying byte provider)
-
hasNext
public boolean hasNext()Returns true if this stream has data that could be read at the current position.- Returns:
- true if there are more bytes that could be read at the
current index
.
-
hasNext
public boolean hasNext(int count) Returns true if this stream has data that could be read at the current position.- Parameters:
count
- number of bytes to verify- Returns:
- true if there are at least count more bytes that could be read at the
current index
.
-
align
public int align(int alignValue) Advances the current index so that it aligns to the specified value (if not already aligned).For example, if current index was 123 and align value was 16, then current index would be advanced to 128.
- Parameters:
alignValue
- position index alignment- Returns:
- the number of bytes required to align (0..alignValue-1)
-
setPointerIndex
public long setPointerIndex(int index) A convenience method for setting the index using a 32 bit integer.- Parameters:
index
- new index, treated as a 32 bit unsigned integer- Returns:
- previous reader offset for use with
setPointerIndex(long)
to restore previous position.
-
setPointerIndex
public long setPointerIndex(long index) Sets the current index to the specified value. The pointer index will allow the reader to operate as a pseudo-iterator.- Parameters:
index
- the byte provider index value- Returns:
- previous reader offset for use with this method to restore previous position.
-
getPointerIndex
public long getPointerIndex()Returns the current index value.- Returns:
- the current index value
-
getInputStream
Returns an InputStream that is a live view of the BinaryReader's position.Any bytes read with the stream will affect the current position of the BinaryReader, and any change to the BinaryReader's position will affect the next value the inputstream returns.
- Returns:
InputStream
-
peekNextByte
Peeks at the next byte without incrementing the current index.- Returns:
- the next byte
- Throws:
IOException
- if an I/O error occurs
-
peekNextShort
Peeks at the next short without incrementing the current index.- Returns:
- the next short
- Throws:
IOException
- if an I/O error occurs
-
peekNextInt
Peeks at the next integer without incrementing the current index.- Returns:
- the next int
- Throws:
IOException
- if an I/O error occurs
-
peekNextLong
Peeks at the next long without incrementing the current index.- Returns:
- the next long
- Throws:
IOException
- if an I/O error occurs
-
readNextByte
Reads the byte at the current index and then increments the current index bySIZEOF_BYTE
.- Returns:
- the byte at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextUnsignedByte
Reads the unsigned byte at the current index and then increments the current index bySIZEOF_BYTE
.- Returns:
- the unsigned byte at the current index, as an int
- Throws:
IOException
- if an I/O error occurs
-
readNextShort
Reads the short at the current index and then increments the current index bySIZEOF_SHORT
.- Returns:
- the short at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextShort
Reads the short at the current index and then increments the current index bySIZEOF_SHORT
.- Parameters:
dc
-BE
orLE
- Returns:
- the short at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextUnsignedShort
Reads the unsigned short at the current index and then increments the current index bySIZEOF_SHORT
.- Returns:
- the unsigned short at the current index, as an int
- Throws:
IOException
- if an I/O error occurs
-
readNextUnsignedShort
Reads the unsigned short at the current index and then increments the current index bySIZEOF_SHORT
.- Parameters:
dc
-BE
orLE
- Returns:
- the unsigned short at the current index, as an int
- Throws:
IOException
- if an I/O error occurs
-
readNextInt
Reads the integer at the current index and then increments the current index bySIZEOF_INT
.- Returns:
- the integer at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextInt
Reads the integer at the current index and then increments the current index bySIZEOF_INT
.- Parameters:
dc
-BE
orLE
- Returns:
- the integer at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextUnsignedInt
Reads the unsigned integer at the current index and then increments the current index bySIZEOF_INT
.- Returns:
- the unsigned integer at the current index, as a long
- Throws:
IOException
- if an I/O error occurs
-
readNextUnsignedInt
Reads the unsigned integer at the current index and then increments the current index bySIZEOF_INT
.- Parameters:
dc
-BE
orLE
- Returns:
- the unsigned integer at the current index, as a long
- Throws:
IOException
- if an I/O error occurs
-
readNextLong
Reads the long at the current index and then increments the current index bySIZEOF_LONG
.- Returns:
- the long at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextLong
Reads the long at the current index and then increments the current index bySIZEOF_LONG
.- Parameters:
dc
-BE
orLE
- Returns:
- the long at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextValue
Returns the signed value of the integer (of the specified length) at the current index.- Parameters:
len
- the number of bytes that the integer occupies, 1 to 8- Returns:
- value of requested length, with sign bit extended, in a long
- Throws:
IOException
- if an I/O error occurs
-
readNextValue
Returns the signed value of the integer (of the specified length) at the current index.- Parameters:
dc
-BE
orLE
len
- the number of bytes that the integer occupies, 1 to 8- Returns:
- value of requested length, with sign bit extended, in a long
- Throws:
IOException
- if an I/O error occurs
-
readNextUnsignedValue
Returns the unsigned value of the integer (of the specified length) at the current index.- Parameters:
len
- the number of bytes that the integer occupies, 1 to 8- Returns:
- unsigned value of requested length, in a long
- Throws:
IOException
- if an I/O error occurs
-
readNextUnsignedValue
Returns the unsigned value of the integer (of the specified length) at the current index.- Parameters:
dc
-BE
orLE
len
- the number of bytes that the integer occupies, 1 to 8- Returns:
- unsigned value of requested length, in a long
- Throws:
IOException
- if an I/O error occurs
-
readNextAsciiString
Reads a null terminated US-ASCII string starting at the current index, advancing the current index by the length of the string that was found.Note: this method no longer trims() the returned String.
- Returns:
- the US-ASCII string at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextAsciiString
Reads a fixed length US-ASCII string starting at the current index, advancing the current index by the specified fixed length.Trailing null terminator characters will be removed. (suitable for reading a string from a fixed length field that is padded with trailing null chars)
Note: this method no longer trims() the returned String.
- Parameters:
length
- number of bytes to read- Returns:
- the US-ASCII string at the current index
- Throws:
IOException
-
readNextUnicodeString
Reads a null-terminated UTF-16 Unicode string at the current index, advancing the current index by the length of the string that was found.- Returns:
- UTF-16 string at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextUnicodeString
Reads a fixed length UTF-16 Unicode string at the current index, advancing the current index by the length of the string that was found.- Parameters:
charCount
- number of UTF-16 characters to read (not bytes)- Returns:
- the UTF-16 Unicode string at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextUtf8String
Reads a null-terminated UTF-8 string at the current index, advancing the current index by the length of the string that was found.- Returns:
- UTF-8 string at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextUtf8String
Reads a fixed length UTF-8 string the current index, advancing the current index by the length of the string that was found.- Parameters:
length
- number of bytes to read- Returns:
- the UTF-8 string at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextByteArray
Reads a byte array ofnElements
starting at the current index and then increments the current index bySIZEOF_BYTE * nElements
.- Returns:
- the byte array starting at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextShortArray
Reads a short array ofnElements
starting at the current index and then increments the current index bySIZEOF_SHORT * nElements
.- Returns:
- the short array starting at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextIntArray
Reads an integer array ofnElements
starting at the current index and then increments the current index bySIZEOF_INT * nElements
.- Parameters:
nElements
- number of elements to read- Returns:
- the integer array starting at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextLongArray
Reads a long array ofnElements
starting at the current index and then increments the current index bySIZEOF_LONG * nElements
.- Parameters:
nElements
- number of elements to read- Returns:
- the long array starting at the current index
- Throws:
IOException
- if an I/O error occurs
-
readNextUnsignedIntExact
Reads an unsigned int32 value, and returns it as a java int (instead of a java long).If the value is outside the range of 0..Integer.MAX_VALUE, an InvalidDataException is thrown.
Useful for reading uint32 values that are going to be used in java to allocate arrays or other similar cases where the value must be a java integer.
- Returns:
- the uint32 value read from the stream, if it fits into the range [0..MAX_VALUE] of a java integer
- Throws:
IOException
- if there was an error readingInvalidDataException
- if value can not be held in a java integer
-
readNextUnsignedIntExact
Reads an unsigned int32 value, and returns it as a java int (instead of a java long).If the value is outside the range of 0..Integer.MAX_VALUE, an InvalidDataException is thrown.
Useful for reading uint32 values that are going to be used in java to allocate arrays or other similar cases where the value must be a java integer.
- Parameters:
dc
-BE
orLE
- Returns:
- the uint32 value read from the stream, if it fits into the range [0..MAX_VALUE] of a java integer
- Throws:
IOException
- if there was an error readingInvalidDataException
- if value can not be held in a java integer
-
readAsciiString
Reads a null terminated US-ASCII string, starting at specified index, stopping at the first null character.Note: this method no longer trims() the returned String.
- Parameters:
index
- starting position of the string- Returns:
- US-ASCII string, excluding the trailing null terminator character
- Throws:
IOException
- if error reading bytes
-
readAsciiString
Reads an fixed length US-ASCII string starting atindex
.Trailing null terminator characters will be removed. (suitable for reading a string from a fixed length field that is padded with trailing null chars)
Note: this method no longer trims() the returned String.
- Parameters:
index
- where the string beginslength
- number of bytes to read- Returns:
- the US-ASCII string
- Throws:
IOException
- if an I/O error occurs
-
readUnicodeString
Reads a null-terminated UTF-16 Unicode string starting atindex
and using the pre-specifiedendianness
.The end of the string is denoted by a two-byte (ie. short)
null
character.- Parameters:
index
- where the UTF-16 Unicode string begins- Returns:
- the UTF-16 Unicode string
- Throws:
IOException
- if an I/O error occurs
-
readUnicodeString
Reads a fixed length UTF-16 Unicode string oflength
characters starting atindex
, using the pre-specifiedendianness
.Trailing null terminator characters will be removed. (suitable for reading a string from a fixed length field that is padded with trailing null chars)
- Parameters:
index
- the index where the UTF-16 Unicode string beginscharCount
- the number of UTF-16 character elements to read.- Returns:
- the UTF-16 Unicode string
- Throws:
IOException
- if an I/O error occurs
-
readUtf8String
Reads a null-terminated UTF-8 string starting atindex
.- Parameters:
index
- where the UTF-8 string begins- Returns:
- the string
- Throws:
IOException
- if an I/O error occurs
-
readUtf8String
Reads a fixed length UTF-8 string oflength
bytes starting atindex
.Trailing null terminator characters will be removed. (suitable for reading a string from a fixed length field that is padded with trailing null chars)
- Parameters:
index
- the index where the UTF-8 string beginslength
- the number of bytes to read- Returns:
- the string
- Throws:
IOException
- if an I/O error occurs
-
readByte
Returns the signed BYTE atindex
.- Parameters:
index
- the index where the BYTE begins- Returns:
- the signed BYTE
- Throws:
IOException
- if an I/O error occurs
-
readUnsignedByte
Returns the unsigned BYTE atindex
.- Parameters:
index
- the index where the BYTE begins- Returns:
- the unsigned BYTE as an int
- Throws:
IOException
- if an I/O error occurs
-
readShort
Returns the signed SHORT atindex
.- Parameters:
index
- the index where the SHORT begins- Returns:
- the signed SHORT
- Throws:
IOException
- if an I/O error occurs
-
readShort
Returns the signed SHORT atindex
.- Parameters:
dc
-BE
orLE
index
- the index where the SHORT begins- Returns:
- the signed SHORT
- Throws:
IOException
- if an I/O error occurs
-
readUnsignedShort
Returns the unsigned SHORT atindex
.- Parameters:
index
- the index where the SHORT begins- Returns:
- the unsigned SHORT as an int
- Throws:
IOException
- if an I/O error occurs
-
readUnsignedShort
Returns the unsigned SHORT atindex
.- Parameters:
dc
-BE
orLE
index
- the index where the SHORT begins- Returns:
- the unsigned SHORT as an int
- Throws:
IOException
- if an I/O error occurs
-
readInt
Returns the signed INTEGER atindex
.- Parameters:
index
- the index where the INTEGER begins- Returns:
- the signed INTEGER
- Throws:
IOException
- if an I/O error occurs
-
readInt
Returns the signed INTEGER atindex
.- Parameters:
dc
-BE
orLE
index
- the index where the INTEGER begins- Returns:
- the signed INTEGER
- Throws:
IOException
- if an I/O error occurs
-
readUnsignedInt
Returns the unsigned INTEGER atindex
.- Parameters:
index
- the index where the INTEGER begins- Returns:
- the unsigned INTEGER as a long
- Throws:
IOException
- if an I/O error occurs
-
readUnsignedInt
Returns the unsigned INTEGER atindex
.- Parameters:
dc
-BE
orLE
index
- the index where the INTEGER begins- Returns:
- the unsigned INTEGER as a long
- Throws:
IOException
- if an I/O error occurs
-
readLong
Returns the signed LONG atindex
.- Parameters:
index
- the index where the LONG begins- Returns:
- the LONG
- Throws:
IOException
- if an I/O error occurs
-
readLong
Returns the signed LONG atindex
.- Parameters:
dc
-BE
orLE
index
- the index where the LONG begins- Returns:
- the LONG
- Throws:
IOException
- if an I/O error occurs
-
readValue
Returns the signed value of the integer (of the specified length) at the specified offset.- Parameters:
index
- where the value beginslen
- the number of bytes that the integer occupies, 1 to 8- Returns:
- value of requested length, with sign bit extended, in a long
- Throws:
IOException
- if an I/O error occurs
-
readValue
Returns the signed value of the integer (of the specified length) at the specified offset.- Parameters:
dc
-BE
orLE
index
- where the value beginslen
- the number of bytes that the integer occupies, 1 to 8- Returns:
- value of requested length, with sign bit extended, in a long
- Throws:
IOException
- if an I/O error occurs
-
readUnsignedValue
Returns the unsigned value of the integer (of the specified length) at the specified offset.- Parameters:
index
- where the value beginslen
- the number of bytes that the integer occupies, 1 to 8- Returns:
- unsigned value of requested length, in a long
- Throws:
IOException
- if an I/O error occurs
-
readUnsignedValue
Returns the unsigned value of the integer (of the specified length) at the specified offset.- Parameters:
dc
-BE
orLE
index
- where the value beginslen
- the number of bytes that the integer occupies, 1 to 8- Returns:
- unsigned value of requested length, in a long
- Throws:
IOException
- if an I/O error occurs
-
readByteArray
Returns the BYTE array ofnElements
starting atindex
.- Parameters:
index
- the index where the BYTE beginsnElements
- the number of array elements- Returns:
- the BYTE array
- Throws:
IOException
- if an I/O error occurs
-
readShortArray
Returns the SHORT array ofnElements
starting atindex
.- Parameters:
index
- the index where the SHORT beginsnElements
- the number of array elements- Returns:
- the SHORT array
- Throws:
IOException
- if an I/O error occurs
-
readIntArray
Returns the INTEGER array ofnElements
starting atindex
.- Parameters:
index
- the index where the INTEGER beginsnElements
- the number of array elements- Returns:
- the INTEGER array
- Throws:
IOException
- if an I/O error occurs
-
readLongArray
Returns the LONG array ofnElements
starting atindex
.- Parameters:
index
- the index where the LONG beginsnElements
- the number of array elements- Returns:
- the LONG array
- Throws:
IOException
- if an I/O error occurs
-
getByteProvider
Returns the underlying byte provider.- Returns:
- the underlying byte provider
-
readNextVarInt
public int readNextVarInt(BinaryReader.ReaderFunction<Long> func) throws IOException, InvalidDataException Reads a variable length / unknown format integer from the current position, using the supplied reader function, returning it (if it fits) as a 32 bit java integer.- Parameters:
func
-BinaryReader.ReaderFunction
- Returns:
- signed int32
- Throws:
IOException
- if error reading or if the value does not fit into a 32 bit java intInvalidDataException
- if value can not be held in a java integer
-
readNextVarInt
public int readNextVarInt(BinaryReader.InputStreamReaderFunction<Long> func) throws IOException, InvalidDataException Reads a variable length / unknown format integer from the current position, using the supplied reader function, returning it (if it fits) as a 32 bit java integer.- Parameters:
func
-BinaryReader.InputStreamReaderFunction
- Returns:
- signed int32
- Throws:
IOException
- if error reading or if the value does not fit into a 32 bit java intInvalidDataException
- if value can not be held in a java integer
-
readNextUnsignedVarIntExact
public int readNextUnsignedVarIntExact(BinaryReader.ReaderFunction<Long> func) throws IOException, InvalidDataException Reads a variable length / unknown format unsigned integer from the current position, using the supplied reader function, returning it (if it fits) as a 32 bit java integer.- Parameters:
func
-BinaryReader.ReaderFunction
- Returns:
- unsigned int32
- Throws:
IOException
- if error reading dataInvalidDataException
- if value can not be held in a java integer
-
readNextUnsignedVarIntExact
public int readNextUnsignedVarIntExact(BinaryReader.InputStreamReaderFunction<Long> func) throws IOException, InvalidDataException Reads a variable length / unknown format unsigned integer from the current position, using the supplied reader function, returning it (if it fits) as a 32 bit java integer.- Parameters:
func
-BinaryReader.InputStreamReaderFunction
- Returns:
- unsigned int32
- Throws:
IOException
- if error reading dataInvalidDataException
- if value can not be held in a java integer
-
readNext
Reads an object from the current position, using the supplied reader function.- Type Parameters:
T
- type of the object that will be returned- Parameters:
func
-BinaryReader.ReaderFunction
that will read and return an object- Returns:
- new object of type T
- Throws:
IOException
- if error reading
-
readNext
Reads an object from the current position, using the supplied reader function.- Type Parameters:
T
- type of the object that will be returned- Parameters:
func
-BinaryReader.InputStreamReaderFunction
that will read and return an object- Returns:
- new object of type T
- Throws:
IOException
- if error reading
-