static public void packInt(DataOutput out,int value) throws IOException {
  int shift=(value & ~0x7F);
  if (shift != 0) {
    shift=31 - Integer.numberOfLeadingZeros(value);
    shift-=shift % 7;
    while (shift != 0) {
      out.writeByte((byte)((value >>> shift) & 0x7F));
      shift-=7;
    }
  }
  out.writeByte((byte)((value & 0x7F) | 0x80));
}

static public void packInt ( DataOutput out , int value ) throws IOException { int shift = ( value & ~ 0x7F ) ; if ( shift != 0 ) { shift = 31 - Integer . numberOfLeadingZeros ( value ) ; shift -= shift % 7 ; while ( shift != 0 ) { out . writeByte ( ( byte ) ( ( value > > > shift ) & 0x7F ) ) ; shift -= 7 ; } } out . writeByte ( ( byte ) ( ( value & 0x7F ) | 0x80 ) ) ; }
pack int into an output stream . it will occupy 1 - 5 bytes depending on value ( lower values occupy smaller space )
