Here you can find the source of readByteBuffer(ByteBuffer buf)
public static byte[] readByteBuffer(ByteBuffer buf)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static byte[] readByteBuffer(ByteBuffer buf) { int pos = buf.position(); byte[] r = new byte[buf.limit() - buf.position()]; buf.get(r);/*from w ww. j ava 2 s . c om*/ buf.position(pos); return r; } }