The list of methods to do ByteBuffer Get are organized into topic(s).
byte[]
get(ByteBuffer source) get
if (source.hasArray()) {
return source.array();
} else {
source.rewind();
System.out.println(source.limit());
byte[] array = new byte[source.limit()];
for (int i = 0; i < array.length; i++) {
array[i] = source.get();
...
byte[]
getActiveArray(ByteBuffer buffer) get Active Array
byte[] ret = new byte[buffer.remaining()];
if (buffer.hasArray()) {
byte[] array = buffer.array();
System.arraycopy(array, buffer.arrayOffset() + buffer.position(), ret, 0, ret.length);
} else {
buffer.slice().get(ret);
return ret;
...
long
getAddress(ByteBuffer buf) get Address
try {
long address;
address = ADDRESS_FIELD.getLong(buf);
return address;
} catch (Exception x) {
throw new RuntimeException(x);
long
getAddress(ByteBuffer buffer) get Address
Preconditions.checkArgument(buffer.isDirect(), "ByteBuffer must be DirectBuffer");
return ((DirectBuffer) buffer).address();
long
getAddressFromDirectByteBuffer(ByteBuffer buffer) Gets the address value for the memory that backs a direct byte buffer.
try {
Field addressField = Buffer.class.getDeclaredField("address");
addressField.setAccessible(true);
return addressField.getLong(buffer);
} catch (Exception e) {
throw new RuntimeException("Unable to address field from ByteBuffer", e);
byte[]
getArray(ByteBuffer buffer) You should almost never use this.
int length = buffer.remaining();
if (buffer.hasArray()) {
int boff = buffer.arrayOffset() + buffer.position();
if (boff == 0 && length == buffer.array().length)
return buffer.array();
else
return Arrays.copyOfRange(buffer.array(), boff, boff + length);
byte[] bytes = new byte[length];
buffer.duplicate().get(bytes);
return bytes;