Java Utililty Methods ByteBuffer Capacity

List of utility methods to do ByteBuffer Capacity

Description

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

Method

ByteBufferleByteBuffer(int capacity)
le Byte Buffer
byte[] underlying = new byte[capacity];
return ByteBuffer.wrap(underlying).order(ByteOrder.LITTLE_ENDIAN);
ByteBuffernativeByteBuffer(int capacity)
native Byte Buffer
ByteBuffer buffer = ByteBuffer.allocateDirect(capacity);
buffer.order(ByteOrder.nativeOrder());
return buffer;
ByteBuffernewByteBuffer(int margin, int capacity)
new Byte Buffer
ByteBuffer b = ByteBuffer.wrap(new byte[margin + capacity]);
b.position(margin);
b.mark(); 
return b;
ByteBufferparseToByteBuffer(int capacity, String value)
parse To Byte Buffer
ByteBuffer buffer = ByteBuffer.allocate(capacity);
buffer.rewind();
buffer.put(value.getBytes());
buffer.rewind();
return buffer;
ByteBufferresetAddressAndCapacity(final ByteBuffer byteBuffer, final long address, final int capacity)
Set the private address of direct ByteBuffer .
if (!byteBuffer.isDirect()) {
    throw new IllegalArgumentException("Can only change address of direct buffers");
try {
    final Field addressField = Buffer.class.getDeclaredField("address");
    addressField.setAccessible(true);
    addressField.set(byteBuffer, Long.valueOf(address));
    final Field capacityField = Buffer.class.getDeclaredField("capacity");
...