public static int readCompressedInt ( InputStream in ) throws IOException { int b1 = in . read ( ) ; if ( b1 == - 1 ) throw new EOFException ( ) ; if ( ( b1 & 0x80 ) != 0 ) { // 31 bit int b2 = in . read ( ) ; if ( b2 == - 1 ) throw new EOFException ( ) ; int b3 = in . read ( ) ; if ( b3 == - 1 ) throw new EOFException ( ) ; int b4 = in . read ( ) ; if ( b4 == - 1 ) throw new EOFException ( ) ; return ( ( b1 & 0x40 ) == 0 ? 0 : 0xc0000000 ) | ( ( b1 & 0x3f ) << 24 ) | ( b2 << 16 ) | ( b3 << 8 ) | b4 ; } else if ( ( b1 & 0x40 ) != 0 ) { // 22 bit int b2 = in . read ( ) ; if ( b2 == - 1 ) throw new EOFException ( ) ; int b3 = in . read ( ) ; if ( b3 == - 1 ) throw new EOFException ( ) ; return ( ( b1 & 0x20 ) == 0 ? 0 : 0xffe00000 ) | ( ( b1 & 0x1f ) << 16 ) | ( b2 << 8 ) | b3 ; } else if ( ( b1 & 0x20 ) != 0 ) { // 13 bit int b2 = in . read ( ) ; if ( b2 == - 1 ) throw new EOFException ( ) ; return ( ( b1 & 0x10 ) == 0 ? 0 : 0xfffff000 ) | ( ( b1 & 0x0f ) << 8 ) | b2 ; } else { // 5 bit return ( ( b1 & 0x10 ) == 0 ? 0 : 0xfffffff0 ) | ( b1 & 0x0f ) ; } }
Reads a compressed integer from the stream .