List of utility methods to do ByteBuffer to Byte Array Convert
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; |