code: public void writeBit(int value, int number) throws IOException {
      int localNumber = number;
      while (localNumber > 0) {
        localNumber--;
        bitBuffer |= ((value & 1) << bitCount++);
        if (bitCount == 8) {
          createByte();
        }
      }
    }
docs: Write bit.
  
  @param value the value
  @param number the number
  @throws IOException Signals that an I/O exception has occurred.