static int popLength(InputStream stream){
  byte[] lengthBytes=new byte[Integer.SIZE / Byte.SIZE];
  try {
    stream.read(lengthBytes);
  }
 catch (  IOException e) {
    log.error("IOException popping length from input stream: ",e);
    return -1;
  }
  ByteBuffer buffer=ByteBuffer.wrap(lengthBytes);
  buffer.order(ByteOrder.BIG_ENDIAN);
  return buffer.getInt();
}

static int popLength ( InputStream stream ) { byte [ ] lengthBytes = new byte [ Integer . SIZE / Byte . SIZE ] ; try { stream . read ( lengthBytes ) ; } catch ( IOException e ) { log . error ( "IOException popping length from input stream: " , e ) ; return - 1 ; } ByteBuffer buffer = ByteBuffer . wrap ( lengthBytes ) ; buffer . order ( ByteOrder . BIG_ENDIAN ) ; return buffer . getInt ( ) ; }
take the output of lengthvalueencode ( ) and decode it to a message of the given type .
