code: 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;
    }
docs: Pack non-negative int into output stream. It will occupy 1-5 bytes
  depending on value (lower values occupy smaller space)
  
  @param os the data output
  @param value the value
  @return the number of bytes written
  @throws IOException if an error occurs with the stream