public static long readUE7(InputStream stream) throws IOException {
        int i;
        long v = 0;
        int max = 6;
        int read = 0;
        while ((i = stream.read()) >= 0 && read++ < max) {
            v = v << 7;
            if ((i & 128) == 128) {
                // Continues
                v += (i & 127);
            } else {
                // Last value
                v += i;
                break;
            }
        }
        if (i < 0) {
            throw new IOException("Buffer underun; expected one more byte");
        }
        return v;
    }
Gets the integer value that is stored in UTF-8 like fashion, in Big Endian
but with the high bit on each number indicating if it continues or not
tika-core/src/main/java/org/apache/tika/io/EndianUtils.java