Here you can find the source of get(ByteBuffer buffer)
public static byte[] get(ByteBuffer buffer)
//package com.java2s; //License from project: Apache License import java.nio.Buffer; import java.nio.ByteBuffer; import javax.annotation.Nonnegative; public class Main { public static byte[] get(ByteBuffer buffer) { byte[] data = new byte[buffer.limit()]; buffer.get(data);/*ww w. ja v a 2 s . co m*/ return data; } public static <T extends Buffer> T limit(T buffer, @Nonnegative int limit) { return limit(buffer, limit, false); } @SuppressWarnings({ "unchecked" }) public static <T extends Buffer> T limit(T buffer, int limit, boolean adjustToBounds) { return ((T) buffer.limit((adjustToBounds ? Math.min(Math.max(limit, 0), buffer.capacity()) : limit))); } }