()
| 17 | } |
| 18 | |
| 19 | public int readBits() throws IOException { |
| 20 | long result = 0; |
| 21 | long resultPos = 0; |
| 22 | for (int i = 0; i < this.amount; i++) { |
| 23 | if (this.currentPos == LONG_END) { |
| 24 | this.currentPos = 0; |
| 25 | this.currentByte = this.source.readLong(); |
| 26 | } |
| 27 | long bit = (this.currentByte >> this.currentPos) & 1L; |
| 28 | long mask = (bit << resultPos); |
| 29 | result = result | mask; |
| 30 | resultPos++; |
| 31 | this.currentPos++; |
| 32 | } |
| 33 | return (int) result; |
| 34 | } |
| 35 | } |