读取8位数组长度,后跟实际数组数据。
/** 时代Java - N o w J a v a . c o m **/ import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; import java.util.Iterator; import org.apache.log4j.Logger; public class Main{ /** * Reads an 8 bit array length followed by the actual array data. * * @param buf * @return the array read */ final static public byte[] readArray8(ByteBuffer buf) { int length = getUnsignedByte(buf); byte[] array = new byte[length]; buf.get(array); return array; } /** * Returns 8 unsigned bits as an integer. * * @param buf * @return */ final public