private int putLength(int len,OutputStream out) throws IOException {
  int retVal=0;
  if (len < 128) {
    out.write((byte)len);
    retVal=1;
  }
 else   if (len < (1 << 8)) {
    out.write((byte)0x081);
    out.write((byte)len);
    retVal=2;
  }
 else   if (len < (1 << 16)) {
    out.write((byte)0x082);
    out.write((byte)(len >> 8));
    out.write((byte)len);
    retVal=3;
  }
 else   if (len < (1 << 24)) {
    out.write((byte)0x083);
    out.write((byte)(len >> 16));
    out.write((byte)(len >> 8));
    out.write((byte)len);
    retVal=4;
  }
 else {
    out.write((byte)0x084);
    out.write((byte)(len >> 24));
    out.write((byte)(len >> 16));
    out.write((byte)(len >> 8));
    out.write((byte)len);
    retVal=5;
  }
  return retVal;
}

private int putLength ( int len , OutputStream out ) throws IOException { int retVal = 0 ; if ( len < 128 ) { out . write ( ( byte ) len ) ; retVal = 1 ; } else if ( len < ( 1 << 8 ) ) { out . write ( ( byte ) 0x081 ) ; out . write ( ( byte ) len ) ; retVal = 2 ; } else if ( len < ( 1 << 16 ) ) { out . write ( ( byte ) 0x082 ) ; out . write ( ( byte ) ( len > > 8 ) ) ; out . write ( ( byte ) len ) ; retVal = 3 ; } else if ( len < ( 1 << 24 ) ) { out . write ( ( byte ) 0x083 ) ; out . write ( ( byte ) ( len > > 16 ) ) ; out . write ( ( byte ) ( len > > 8 ) ) ; out . write ( ( byte ) len ) ; retVal = 4 ; } else { out . write ( ( byte ) 0x084 ) ; out . write ( ( byte ) ( len > > 24 ) ) ; out . write ( ( byte ) ( len > > 16 ) ) ; out . write ( ( byte ) ( len > > 8 ) ) ; out . write ( ( byte ) len ) ; retVal = 5 ; } return retVal ; }
put the encoding of the length in the specified stream .
