Java Utililty Methods ByteBuffer Allocate

List of utility methods to do ByteBuffer Allocate

Description

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

Method

DoubleBufferallocateDoubles(final int howmany, final int SIZE)
allocate Doubles
return ByteBuffer.allocateDirect(howmany * SIZE).order(ByteOrder.nativeOrder()).asDoubleBuffer();
FloatBufferallocateFloats(final int howmany, final int SIZE)
allocate Floats
return ByteBuffer.allocateDirect(howmany * SIZE).order(ByteOrder.nativeOrder()).asFloatBuffer();
IntBufferallocateInt()
Get an IntBuffer of size 4 with Little Endian Byte Order
ByteBuffer status = ByteBuffer.allocateDirect(4);
status.order(ByteOrder.LITTLE_ENDIAN);
return status.asIntBuffer();
IntBufferallocateInts(final int[] intarray, final int SIZE)
allocate Ints
IntBuffer ib = ByteBuffer.allocateDirect(intarray.length * SIZE).order(ByteOrder.nativeOrder())
        .asIntBuffer();
ib.put(intarray).flip();
return ib;
ByteBufferallocateNativeOrderDirectBuffer(int size)
allocate Native Order Direct Buffer
ByteBuffer buf = allocateBuffer(size, true);
buf.order(ByteOrder.nativeOrder());
return buf;
ByteBufferallocateTestBuffer(int capacity, boolean direct)
allocate Test Buffer
ByteBuffer bb;
if (direct) {
    bb = ByteBuffer.allocateDirect(capacity);
} else {
    bb = ByteBuffer.allocate(capacity);
for (int i = 0; i < capacity; i++) {
    bb.put((byte) (i & 0xff));
...
voidfromBytes(byte[] data, boolean[] preAllocatedValues)
from Bytes
final ByteBuffer byteBuffer = ByteBuffer.wrap(data);
for (int i = 0; i < preAllocatedValues.length; i++) {
    preAllocatedValues[i] = byteBuffer.get() == 1;