code: public static int readUnsignedInt(byte[] bytes, int offset) {
        byte b = bytes[offset++];
        int i = b & 0x7F;
        for (int shift = 7; (b & 0x80) != 0; shift += 7) {
           b = bytes[offset++];
           i |= (b & 0x7FL) << shift;
        }
        return i;
     }
docs: Reads an int stored in variable-length format.  Reads between one and five bytes.  Smaller values take fewer
  bytes.  Negative numbers are not supported.