/** * Returns an int value representing the value of the bits read from * the byte array, from the current position. Bits are extracted from the * "left side" or high side of the byte.<p> * The current position is modified by this call.<p> * Bits are pushed into the int from the right, endianness is not * considered by the method on its own. So, if 5 bits were read from the * buffer "10101", the int would be the integer representation of * 000...0010101 on the target machine. <p> * In general, this also means the result will be positive unless a full * 32 bits are read. <p> * Requesting more than 32 bits is allowed, but only up to 32 bits worth of * data will be returned (the last 32 bits read). <p> * * @param bitsToRead the number of bits to read from the bit buffer * @return the value of the bits read */ public int getBits(int bitsToRead) { return this.buffer.getBits(bitsToRead); }
/** * Returns an int value representing the value of the bits read from * the byte array, from the current position. Bits are extracted from the * "left side" or high side of the byte.<p> * The current position is modified by this call.<p> * Bits are pushed into the int from the right, endianness is not * considered by the method on its own. So, if 5 bits were read from the * buffer "10101", the int would be the integer representation of * 000...0010101 on the target machine. <p> * In general, this also means the result will be positive unless a full * 32 bits are read. <p> * Requesting more than 32 bits is allowed, but only up to 32 bits worth of * data will be returned (the last 32 bits read). <p> * * @param bitsToRead the number of bits to read from the bit buffer * @return the value of the bits read */ public int getBits(int bitsToRead) { return this.buffer.getBits(bitsToRead); }
BitBuffer bb = new BitBuffer(out.toByteArray()); for (int i=0; i<values.length; i++) { int value = bb.getBits(bits[i]); if (value != values[i]) { LOGGER.info("Value #{} does not match (got {}; expected {}; {} bits)", bb = new BitBuffer(out.toByteArray()); for (int i = 0; i < 5000; i++) { int value = bb.getBits(1); int expected = (sb.charAt(i) == '1') ? 1 : 0; if (value != expected) {
int c = r.nextInt(100); if (c > 50) { readint = bb.getBits(len[i]); if (readint != nums[i]) { LOGGER.info("Error at #{}: {} received, {} expected.", int read = bb.getBits(1); if (-1 != read) { LOGGER.info("-1 expected at end of buffer, {} received.", read); if (c > 50) { if (len[i] > 8) { bb.getBits(8); if (!bb.isBitOnByteBoundary()){ LOGGER.info("Bit on byte boundary expected, but not returned.");