Android Utililty Methods ByteBuffer to Byte Array Convert

List of utility methods to do ByteBuffer to Byte Array Convert

Description

The list of methods to do ByteBuffer to Byte Array Convert are organized into topic(s).

Method

byte[]toBytes(ByteBuffer buffer, int startPosition)
Copy the bytes from position to limit into a new byte[] of the exact length and sets the position and limit back to their original values (though not thread safe).
int originalPosition = buffer.position();
byte[] output = new byte[buffer.limit() - startPosition];
buffer.position(startPosition);
buffer.get(output);
buffer.position(originalPosition);
return output;