code: public int readBit() throws IOException {
      if (bitCount == 0) {
        bitBuffer = read();
        if (bitBuffer == -1) {
          throw new IOException("no more bits");
        }
      }
      int value = (bitBuffer >> bitCount) & 1;
      bitCount++;
      if (bitCount > 7) {
        bitCount = 0;
      }
      return value;
    }
docs: Read bit.
  
  @return the int
  @throws IOException Signals that an I/O exception has occurred.