Java Utililty Methods ByteBuffer to Int Array

List of utility methods to do ByteBuffer to Int Array

Description

The list of methods to do ByteBuffer to Int Array are organized into topic(s).

Method

int[]getIntArray(ByteBuffer data, int offset, int length)
get Int Array
if (length == 0) {
    return new int[0];
data.position(offset);
int[] intArray = new int[length / 2];
int index = 0;
while (index < intArray.length) {
    intArray[index++] = data.getShort();
...
intgetIntBE(ByteBuffer b, int start, int end)
get Int BE
return (int) getLongBE(b, start, end);
intgetIntBE(final ByteBuffer b, final int start, final int end)
Computes a number whereby the 1st byte is the most significant and the last byte is the least significant.
return (int) getLongBE(b, start, end);
ByteBuffergetIntByteBuffer(int id)
get Int Byte Buffer
ByteBuffer buffer = ByteBuffer.allocate(intSize);
buffer.putInt(id);
buffer.flip();
return buffer;
intgetIntegerFromBuffer(ByteBuffer buffer, int offset, int size)
Gets integer from buffer
int data = 0;
try {
    if (size == 1) {
        data |= buffer.get(offset);
    } else if (size == 2) {
        data |= buffer.getShort(offset) & 0xFFFF;
        data = Short.reverseBytes((short) data);
    } else if (size == 4) {
...
intgetIntFromBack(ByteBuffer bb)
get Int From Back
int val = bb.getInt(bb.limit() - 4);
bb.limit(bb.limit() - 4);
return val;
IntegergetIntFromByteBuffer(ByteBuffer data)
int from ByteBuffer
return getIntFromBytes(data.array());
intgetIntWithChecksum(ByteBuffer buffer, Adler32 checksum)
get Int With Checksum
final int value = buffer.getInt();
checksum.update(value);
return value;
int[]readIntArray(ByteBuffer bb)
read Int Array
int ints[] = null;
int size = bb.getInt();
if (size >= 0) {
    ints = new int[size];
    byte[] b = new byte[size * 4];
    bb.get(b);
    int l = 0;
    for (int i = 0; i < b.length; i += 4) {
...
int[]readIntArray(ByteBuffer buf)
No array length
final int size = buf.getInt();
int[] arr = new int[size];
for (int i = 0; i < size; i++) {
    arr[i] = buf.getInt();
return arr;