Here you can find the source of readToBytes(ByteBuffer byteBuffer)
public static byte[] readToBytes(ByteBuffer byteBuffer)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { public static byte[] readToBytes(ByteBuffer byteBuffer) { int remain = byteBuffer.remaining(); byte[] data = new byte[remain]; byteBuffer.get(data);/*from w ww . ja v a 2 s . c o m*/ return data; } }