Here you can find the source of readBytes(ByteBuffer buffer, int length)
public static byte[] readBytes(ByteBuffer buffer, int length)
//package com.java2s; //License from project: Apache License import java.nio.ByteBuffer; public class Main { public static byte[] readBytes(ByteBuffer buffer, int length) { byte[] ab = new byte[length]; buffer.get(ab);//from w w w . j a va 2 s . co m return ab; } }