Here you can find the source of writeByteArray(ByteBuffer byteBuffer, byte[] bytes)
public static void writeByteArray(ByteBuffer byteBuffer, byte[] bytes)
//package com.java2s; /*/*from w w w . j a va 2 s. c o m*/ * (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 void writeByteArray(ByteBuffer byteBuffer, byte[] bytes) { byteBuffer.put(bytes); } public static boolean writeByteArray(ByteBuffer byteBuffer, byte[] bytes, int offset, int length) { if (bytes.length < offset + length) return false; byteBuffer.put(bytes, offset, length); return true; } }