code: public int peekBitToInt(int val, int bit) throws IOException {
          while (true) {
              if (bit < availBits) {
                  val <<= 1;
                  if ((getBit + bit) >= BITS_PER_BLURB) {
                      bit = (getBit + bit) % BITS_PER_BLURB;
                      val |= ((buffer[getByte + 1] & (0x80 >> bit)) != 0) ? 1 : 0;
                  } else {
                      val |= ((buffer[getByte] & (0x80 >> (getBit + bit))) != 0) ? 1 : 0;
                  }
                  return val;
              } else {
                  readFromStream();
              }
          }
      }
docs: peek at the next bit and add it to the input integer.
  The bits of the input integer are shifted left and the
  read bit is placed into bit 0.
  @param val   The input integer
  @param bit   The bit to peek at
  @return      The updated integer value
  @throws IOException  Thrown if error reading input stream