Here you can find the source of asByteArray(ByteBuffer buf)
public static byte[] asByteArray(ByteBuffer buf)
//package com.java2s; import java.nio.ByteBuffer; public class Main { public static byte[] asByteArray(ByteBuffer buf) { byte[] bytes = new byte[buf.remaining()]; buf.get(bytes);/*from w w w .ja va2s . co m*/ return bytes; } }