Here you can find the source of getDataFromBuffer(ByteBuffer b)
public static byte[] getDataFromBuffer(ByteBuffer b)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static byte[] getDataFromBuffer(ByteBuffer b) { int position = b.position(); byte[] data = new byte[position]; b.position(0);/*from w ww . java2 s .c o m*/ b.get(data, 0, data.length); return data; } }