Java tutorial
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static byte[] readByteBuffer(DataInput in) throws Exception { int b = in.readByte(); if (b == 1) { b = in.readInt(); byte[] buf = new byte[b]; in.readFully(buf, 0, buf.length); return buf; } return null; } }