Here you can find the source of toByteArray(ByteBuffer buffer)
public static byte[] toByteArray(ByteBuffer buffer)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { public static byte[] toByteArray(ByteBuffer buffer) { return buffer != null && buffer.hasArray() ? buffer.array() : null; }//from www .j a v a2 s .c om }