Here you can find the source of readByteArray(ByteBuffer logBuf)
public static byte[] readByteArray(ByteBuffer logBuf)
//package com.java2s; /*-//from ww w. j a v a2 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 { private static final boolean DEBUG = false; public static final byte[] ZERO_LENGTH_BYTE_ARRAY = new byte[0]; /** * Read a byte array from the log. The size is stored first as an integer. */ public static byte[] readByteArray(ByteBuffer logBuf) { int size = readInt(logBuf); // how long is it? if (DEBUG) { System.out.println("pos = " + logBuf.position() + " byteArray is " + size + " on read"); } if (size == 0) { return ZERO_LENGTH_BYTE_ARRAY; } byte[] b = new byte[size]; logBuf.get(b); // read it out return b; } /** * Read a int from the log. */ public static int readInt(ByteBuffer logBuf) { int ret = (logBuf.get() & 0xFF) << 0; ret += (logBuf.get() & 0xFF) << 8; ret += (logBuf.get() & 0xFF) << 16; ret += (logBuf.get() & 0xFF) << 24; return ret; } }