Here you can find the source of readSize(ByteBuffer buffer)
public final static int readSize(ByteBuffer buffer)
//package com.java2s; /**/*ww w.j a va2 s .co m*/ * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. */ import java.nio.ByteBuffer; public class Main { public final static int readSize(ByteBuffer buffer) { final byte b = buffer.get(); if (b == -1) return -1; else if (b == -2) { final int s = buffer.getInt(); if (s < 0) throw new RuntimeException("negative array size"); return s; } else return (int) (b < 0 ? b + 256 : b); } }