Here you can find the source of readBytes(byte[] dest, int offset, int length, ByteBuffer buffer)
public static void readBytes(byte[] dest, int offset, int length, ByteBuffer buffer) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.ByteBuffer; public class Main { public static void readBytes(byte[] dest, int offset, int length, ByteBuffer buffer) throws IOException { buffer.get(dest, offset, length); }//from w ww .j a v a 2s . c o m public static byte[] readBytes(int length, ByteBuffer buffer) throws IOException { byte[] bytes = new byte[length]; buffer.get(bytes); return bytes; } }