public long skip(long n) throws IOException {
  if (n <= fill) {
    if (n < 0)     throw new IllegalArgumentException("Negative bit skip value: " + n);
    fill-=n;
    readBits+=n;
    return n;
  }
 else {
    final long prevReadBits=readBits;
    n-=fill;
    readBits+=fill;
    fill=0;
    long nb=n >> 3;
    if (buffer != null && nb > avail && nb < avail + buffer.length) {
      readBits+=(avail + 1) << 3;
      n-=(avail + 1) << 3;
      nb-=avail + 1;
      position+=pos + avail;
      pos=avail=0;
      read();
    }
    if (nb <= avail) {
      pos+=(int)nb;
      avail-=(int)nb;
      readBits+=n & ~7;
    }
 else {
      n-=avail << 3;
      readBits+=avail << 3;
      final long toSkip=nb - avail;
      final long skipped=is.skip(toSkip);
      if (skipped < toSkip)       throw new IOException("skip() has skipped " + skipped + " instead of "+ toSkip+ " bytes");
      position+=(avail + pos) + skipped;
      pos=0;
      avail=0;
      readBits+=skipped << 3;
      if (skipped != toSkip)       return readBits - prevReadBits;
    }
    final int residual=(int)(n & 7);
    if (residual != 0) {
      current=read();
      fill=8 - residual;
      readBits+=residual;
    }
    return readBits - prevReadBits;
  }
}

public long skip ( long n ) throws IOException { if ( n <= fill ) { if ( n < 0 ) throw new IllegalArgumentException ( "Negative bit skip value: " + n ) ; fill -= n ; readBits += n ; return n ; } else { final long prevReadBits = readBits ; n -= fill ; readBits += fill ; fill = 0 ; long nb = n > > 3 ; if ( buffer != null && nb > avail && nb < avail + buffer . length ) { readBits += ( avail + 1 ) << 3 ; n -= ( avail + 1 ) << 3 ; nb -= avail + 1 ; position += pos + avail ; pos = avail = 0 ; read ( ) ; } if ( nb <= avail ) { pos += ( int ) nb ; avail -= ( int ) nb ; readBits += n & ~ 7 ; } else { n -= avail << 3 ; readBits += avail << 3 ; final long toSkip = nb - avail ; final long skipped = is . skip ( toSkip ) ; if ( skipped < toSkip ) throw new IOException ( "skip() has skipped " + skipped + " instead of " + toSkip + " bytes" ) ; position += ( avail + pos ) + skipped ; pos = 0 ; avail = 0 ; readBits += skipped << 3 ; if ( skipped != toSkip ) return readBits - prevReadBits ; } final int residual = ( int ) ( n & 7 ) ; if ( residual != 0 ) { current = read ( ) ; fill = 8 - residual ; readBits += residual ; } return readBits - prevReadBits ; } }
skips the given number of bits .
