Here you can find the source of get(ByteBuffer source)
public static byte[] get(ByteBuffer source)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; public class Main { public static byte[] get(ByteBuffer source) { if (source.hasArray()) { return source.array(); } else {// w ww . ja va2 s.c o m source.rewind(); System.out.println(source.limit()); byte[] array = new byte[source.limit()]; for (int i = 0; i < array.length; i++) { array[i] = source.get(); System.out.println(array[i]); } return array; } } }