private void fillBuffer() throws IOException {
        while (bits < 24) {
            final int nextByte = read();

            if (nextByte != -1) {
                b |= (nextByte & 0xff) << bits;
            }
            bits += 8;
        }
    }
decode an integer in the range 0..max (inclusive).
main/src/main/java/cgeo/geocaching/brouter/util/MixCoderDataInputStream.java