Here you can find the source of toBytes(ByteBuffer buff)
public static byte[] toBytes(ByteBuffer buff)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { public static byte[] toBytes(ByteBuffer buff) { int limit = buff.limit(); byte[] arr = new byte[limit]; System.arraycopy(buff.array(), buff.arrayOffset() + buff.position(), arr, 0, limit); return arr; }//from w ww .j ava 2 s . c om }