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