| java.lang.Object | |
| ↳ | com.pnfsoftware.jeb.util.io.ByteBufferUtil |
Utility methods for ByteBuffers.
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| ByteBufferUtil() | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| static int |
align(ByteBuffer b, int align)
Align the buffer using the provided byte alignment.
| ||||||||||
| static boolean |
equalsByteArray(ByteBuffer b, int bufferOffset, byte[] a, int arrayOffset, int size)
Compare bytes of a buffer against the bytes of an array.
| ||||||||||
| static byte[] |
getBytes(ByteBuffer b, int offset, int size)
Extract a sequence of bytes from a buffer into a newly-created byte array.
| ||||||||||
| static byte[] |
getBytes(ByteBuffer b)
Read the remaining bytes of a buffer.
| ||||||||||
| static long |
getUnsignedInt(ByteBuffer b)
Unpack a 4-byte int and zero-extend it to a long.
| ||||||||||
| static long |
getUnsignedInt(ByteBuffer b, int index)
Unpack a 4-byte int and zero-extend it to a long.
| ||||||||||
| static void |
skip(ByteBuffer b, int n)
Skip bytes, including "backward skipping".
| ||||||||||
| static int |
skipAttempt(ByteBuffer b, int n)
Attempt to skip bytes, including "backward skipping".
| ||||||||||
| static void |
skipToEnd(ByteBuffer b)
Go to the end of the buffer.
| ||||||||||
| static ByteBuffer |
wrapBE(byte[] array, int offset, int length)
Wrap the provided bytes in a big-endian buffer.
| ||||||||||
| static ByteBuffer |
wrapBE(byte[] array)
Wrap the provided bytes in a big-endian buffer.
| ||||||||||
| static ByteBuffer |
wrapLE(byte[] array, int offset, int length)
Wrap the provided bytes in a little-endian buffer.
| ||||||||||
| static ByteBuffer |
wrapLE(byte[] array)
Wrap the provided bytes in a little-endian buffer.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Align the buffer using the provided byte alignment. The position will be increased from anything from 0 to ALIGN-1 bytes so that the new position is congurent to 0 (modulo N).
| align | must be >= 1 |
|---|
Compare bytes of a buffer against the bytes of an array.
| b | source buffer |
|---|---|
| bufferOffset | offset in buffer |
| a | source array |
| arrayOffset | offset in array |
| size | number to bytes to be compared |
Extract a sequence of bytes from a buffer into a newly-created byte array.
| offset | offset in `b` (!) |
|---|---|
| size | number of bytes to read, from `b.position()` |
Read the remaining bytes of a buffer.
Unpack a 4-byte int and zero-extend it to a long.
Unpack a 4-byte int and zero-extend it to a long.
Skip bytes, including "backward skipping". An exception is raised if the exact amount of bytes could not be skipped.
| b | buffer |
|---|---|
| n | number of bytes to skip (move forward); can be negative to partially rewind the pointer |
Attempt to skip bytes, including "backward skipping".
| b | buffer |
|---|---|
| n | number of bytes to skip |
Go to the end of the buffer.
| b | buffer |
|---|
Wrap the provided bytes in a big-endian buffer.
Wrap the provided bytes in a big-endian buffer.
Wrap the provided bytes in a little-endian buffer.
Wrap the provided bytes in a little-endian buffer.