Here you can find the source of getUsedBytes(ByteBuffer bb)
public static byte[] getUsedBytes(ByteBuffer bb)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { public static byte[] getUsedBytes(ByteBuffer bb) { byte[] data = bb.array(); byte[] remain = new byte[bb.position()]; System.arraycopy(data, 0, remain, 0, remain.length); return remain; }/*from www . j a v a 2s. c o m*/ }