List of utility methods to do ByteBuffer Create
void | copy(float[] src, ByteBuffer dst, int numFloats, int offset) copy dst.clear(); dst.limit(numFloats << 2); for (int i = offset; i < offset + numFloats && i < src.length; i++) { dst.put(toByta(Float.floatToRawIntBits(src[i]))); dst.flip(); |
ByteBuffer | newByteBuffer(int numBytes) new Byte Buffer ByteBuffer buffer = ByteBuffer.allocateDirect(numBytes);
buffer.order(ByteOrder.nativeOrder());
return buffer;
|
ByteBuffer | newByteBuffer(int numBytes) new Byte Buffer ByteBuffer buffer = ByteBuffer.allocateDirect(numBytes);
buffer.order(ByteOrder.nativeOrder());
return buffer;
|
ByteBuffer | newUnsafeByteBuffer(ByteBuffer buffer) Registers the given ByteBuffer as an unsafe ByteBuffer. allocatedUnsafe += buffer.capacity(); synchronized (unsafeBuffers) { unsafeBuffers.add(buffer); return buffer; |
ByteBuffer | newUnsafeByteBuffer(int numBytes) Allocates a new direct ByteBuffer from native heap memory using the native byte order. ByteBuffer buffer = newDisposableByteBuffer(numBytes); buffer.order(ByteOrder.nativeOrder()); allocatedUnsafe += numBytes; synchronized (unsafeBuffers) { unsafeBuffers.add(buffer); return buffer; |
ByteBuffer | createByteBuffer(byte[] data) Creates a ByteBuffer from the specified byte array. ByteBuffer b = createByteBuffer(data.length);
b.put(data);
b.rewind();
return b;
|
ByteBuffer | createByteBuffer(int capacity) Creates a ByteBuffer with the specified capacity. ByteBuffer b = ByteBuffer.allocateDirect(capacity);
b.order(ByteOrder.nativeOrder());
return b;
|
ByteBuffer | createByteBuffer(int count) create Byte Buffer ByteBuffer data = ByteBuffer.allocateDirect(count * 4);
data.order(ByteOrder.nativeOrder());
return data;
|
ByteBuffer | createByteBuffer(int size) create Byte Buffer ByteBuffer bf = ByteBuffer.allocateDirect(size);
return bf.order(ByteOrder.nativeOrder());
|
ByteBuffer | createByteBuffer(int size) create Byte Buffer return ByteBuffer.allocateDirect(size).order(
ByteOrder.nativeOrder());
|