public byte [ ] getBitString ( int len ) throws IOException { if ( len > available ( ) ) throw new IOException ( "short read of bit string" ) ; if ( len == 0 ) { throw new IOException ( "Invalid encoding: zero length bit string" ) ; } int numOfPadBits = buf [ pos ] ; if ( ( numOfPadBits < 0 ) || ( numOfPadBits > 7 ) ) { throw new IOException ( "Invalid number of padding bits" ) ; } // minus the first byte which indicates the number of padding bits byte [ ] retval = new byte [ len - 1 ] ; System . arraycopy ( buf , pos + 1 , retval , 0 , len - 1 ) ; if ( numOfPadBits != 0 ) { // get rid of the padding bits retval [ len - 2 ] &= ( 0xff << numOfPadBits ) ; } skip ( len ) ; return retval ; }
Returns the bit string which takes up the specified number of bytes in this buffer .