Here you can find the source of writeByteArray(ByteBuffer logBuf, byte[] b)
public static void writeByteArray(ByteBuffer logBuf, byte[] b)
//package com.java2s; /*-//from w w w .j a v a 2 s. c om * See the file LICENSE for redistribution information. * * Copyright (c) 2002,2007 Oracle. All rights reserved. * * $Id: LogUtils.java,v 1.50.2.1 2007/02/01 14:49:47 cwl Exp $ */ import java.nio.ByteBuffer; public class Main { /** * Write a byte array into the log. The size is stored first as an integer. */ public static void writeByteArray(ByteBuffer logBuf, byte[] b) { /* Write the length. */ writeInt(logBuf, b.length); /* Add the data itself. */ logBuf.put(b); // data } /** * Write an int into the log. */ public static void writeInt(ByteBuffer logBuf, int i) { byte b = (byte) ((i >> 0) & 0xff); logBuf.put(b); b = (byte) ((i >> 8) & 0xff); logBuf.put(b); b = (byte) ((i >> 16) & 0xff); logBuf.put(b); b = (byte) ((i >> 24) & 0xff); logBuf.put(b); } }