Here you can find the source of readByteArray(ByteBuffer byteBuffer, int length)
public static byte[] readByteArray(ByteBuffer byteBuffer, int length)
//package com.java2s; /*//from w w w . j a va 2s . c om * (C) 2007-2010 Alibaba Group Holding Limited. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * */ import java.nio.ByteBuffer; public class Main { public static byte[] readByteArray(ByteBuffer byteBuffer, int length) { byte[] ret = new byte[length]; byteBuffer.get(ret, 0, length); return ret; } }