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

ByteBufferallocate(int capacity)
allocate
ByteBuffer bb = ByteBuffer.allocate(capacity);
bb.order(BYTE_ORDER);
return bb;
ByteBufferallocate(int capacity, boolean direct)
Allocate ByteBuffer.
if (capacity < 0)
    throw new IllegalArgumentException("capacity can't be negative");
return direct ? ByteBuffer.allocateDirect(capacity) : ByteBuffer.allocate(capacity);
ByteBufferallocate(int length)
allocate
return ByteBuffer.allocate(length);
ByteBufferallocate(int length, byte fillwith)
allocate
byte[] bytes = new byte[length];
for (int i = 0; i < length; i++)
    bytes[i] = fillwith;
return ByteBuffer.wrap(bytes);
ByteBufferallocate(int size)
allocate
return ByteBuffer.allocate(size).order(STORED_BYTE_ORDER);
ByteBufferallocate(int size)
allocate
if (size > DIRECT_THRESHOLD) {
    return ByteBuffer.allocateDirect(size);
} else {
    try {
        return ByteBuffer.allocate(size);
    } catch (OutOfMemoryError ex) {
        return ByteBuffer.allocateDirect(size);
ByteBufferallocateBuffer(int size, boolean isDirect)
allocate Buffer
final ByteBuffer buffer;
if (isDirect) {
    buffer = ByteBuffer.allocateDirect(size);
} else {
    buffer = ByteBuffer.allocate(size);
return buffer;
ByteBufferallocateDirect(int capacity)
Allocate ByteBuffer in flush mode.
ByteBuffer buf = ByteBuffer.allocateDirect(capacity);
buf.limit(0);
return buf;
ByteBufferallocateDirectBuffer(int size)
allocate Direct Buffer
if (size > directBufferSize) {
    directBufferSize = size;
    directBuffer = ByteBuffer.allocateDirect(directBufferSize).order(ByteOrder.nativeOrder());
directBuffer.clear();
directBuffer.limit(size);
return directBuffer;
IntBufferallocateDirectInt(int size)
allocate Direct Int
ByteBuffer bb = ByteBuffer.allocateDirect(size * 4);
bb.order(ByteOrder.nativeOrder());
return bb.asIntBuffer();