### Question:
BytesUtil { public static byte[] readBytesFromByteBuffer(ByteBuffer byteBuffer) { byte[] buffer = new byte[byteBuffer.remaining()]; byteBuffer.get(buffer); return buffer; }  static byte[] readBytesFromByteBufferWithoutConsume(ByteBuffer byteBuffer); static byte[] readBytesFromByteBuffer(ByteBuffer byteBuffer);  }### Answer:
@Test public void testReadBytesFromByteBuffer() { byte[] expectedBytes = "hello world".getBytes(); ByteBuffer bb = ByteBuffer.wrap(expectedBytes); byte[] returnedBytes = BytesUtil.readBytesFromByteBuffer(bb); assertArrayEquals(expectedBytes, returnedBytes); assertEquals(expectedBytes.length, bb.position()); }