Package com.pnfsoftware.jeb.util.io
Class ChannelHelper
java.lang.Object
com.pnfsoftware.jeb.util.io.ChannelHelper
Helper for
SeekableByteChannels.
The provided channel is neither closed nor position-verified. Methods of this class are not thread-safe.
-
Constructor Summary
ConstructorsConstructorDescriptionChannelHelper(SeekableByteChannel channel, Endianness endianness) Create a primitive reader helper for a seekable byte channel. -
Method Summary
Modifier and TypeMethodDescriptionbyteget()Read one byte at the current channel position.byteget(long channelPosition) Read one byte at an absolute channel position.intgetInt()Read a 32-bit integer at the current channel position.intgetInt(long channelPosition) Read a 32-bit integer at an absolute channel position.longgetLong()Read a 64-bit integer at the current channel position.longgetLong(long channelPosition) Read a 64-bit integer at an absolute channel position.shortgetShort()Read a 16-bit integer at the current channel position.shortgetShort(long channelPosition) Read a 16-bit integer at an absolute channel position.
-
Constructor Details
-
ChannelHelper
Create a primitive reader helper for a seekable byte channel.- Parameters:
channel- input channelendianness- byte order to use when reading multi-byte values
-
-
Method Details
-
get
Read one byte at the current channel position.- Returns:
- byte value
- Throws:
IOException- if the byte cannot be read
-
get
Read one byte at an absolute channel position.- Parameters:
channelPosition- absolute channel position- Returns:
- byte value
- Throws:
IOException- if the byte cannot be read
-
getShort
Read a 16-bit integer at the current channel position.- Returns:
- decoded value
- Throws:
IOException- if the value cannot be read
-
getShort
Read a 16-bit integer at an absolute channel position.- Parameters:
channelPosition- absolute channel position- Returns:
- decoded value
- Throws:
IOException- if the value cannot be read
-
getInt
Read a 32-bit integer at the current channel position.- Returns:
- decoded value
- Throws:
IOException- if the value cannot be read
-
getInt
Read a 32-bit integer at an absolute channel position.- Parameters:
channelPosition- absolute channel position- Returns:
- decoded value
- Throws:
IOException- if the value cannot be read
-
getLong
Read a 64-bit integer at the current channel position.- Returns:
- decoded value
- Throws:
IOException- if the value cannot be read
-
getLong
Read a 64-bit integer at an absolute channel position.- Parameters:
channelPosition- absolute channel position- Returns:
- decoded value
- Throws:
IOException- if the value cannot be read
-