static public int packInt(DataOutput os,int value) throws IOException {
  if (value < 0) {
    throw new IllegalArgumentException("negative value: v=" + value);
  }
  int i=1;
  while ((value & ~0x7F) != 0) {
    os.write(((value & 0x7F) | 0x80));
    value>>>=7;
    i++;
  }
  os.write((byte)value);
  return i;
}

static public int packInt ( DataOutput os , int value ) throws IOException { if ( value < 0 ) { throw new IllegalArgumentException ( "negative value: v=" + value ) ; } int i = 1 ; while ( ( value & ~ 0x7F ) != 0 ) { os . write ( ( ( value & 0x7F ) | 0x80 ) ) ; value >>>= 7 ; i ++ ; } os . write ( ( byte ) value ) ; return i ; }
pack non - negative int into output stream . it will occupy 1 - 5 bytes depending on value ( lower values occupy smaller space )
