| 123 | } |
| 124 | |
| 125 | public void skip(long totalBits) throws IOException { |
| 126 | final int availableBits = 8 - currentIdx; |
| 127 | if (totalBits <= availableBits) { |
| 128 | currentIdx += totalBits; |
| 129 | } else { |
| 130 | final long bitsToSkip = (totalBits - availableBits); |
| 131 | input.skip(bitsToSkip / 8); |
| 132 | // Edge case: when skipping the last bits of a bitField there is nothing more to read! |
| 133 | if (input.hasNext()) { |
| 134 | current = input.next(); |
| 135 | currentIdx = (byte) (bitsToSkip % 8); |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | @Override |
| 141 | public String toString() { |