### Question:
BinaryUtils { public static InputStream toStream(ByteBuffer byteBuffer) { final byte[] bytes = new byte[byteBuffer.remaining()]; byteBuffer.get(bytes); return new ByteArrayInputStream(bytes); }  static String toHex(byte[] data); static byte[] fromHex(String hexData); static String toBase64(byte[] data); static byte[] fromBase64(String b64Data); static InputStream toStream(ByteBuffer byteBuffer); static byte[] copyAllBytesFrom(ByteBuffer bb);  }### Answer:
@Test public void testByteBufferToStream() throws IOException { byte[] content = "content".getBytes(StringUtils.UTF8); ByteBuffer bb = ByteBuffer.wrap(content); InputStream is = BinaryUtils.toStream(bb); int curr = -1; ByteArrayOutputStream baos = new ByteArrayOutputStream(); while ((curr = is.read()) != -1) { baos.write(curr); } assertArrayEquals(content, baos.toByteArray()); }