code: public void writeBit(final int bit)
  		throws EncodingException
  	{
  
  		if (bit != 0 && bit != 1) {
  			throw ErrorFactory.createEncodingException(
  					ErrorKeys.DIFFTOOL_ENCODING_VALUE_OUT_OF_RANGE,
  					"bit value out of range: " + bit);
  		}
  
  		this.buffer |= bit << (7 - this.bufferLength);
  		this.bufferLength++;
  
  		if (bufferLength == 8) {
  
  			write(buffer);
  
  			this.bufferLength = 0;
  			this.buffer = 0;
  		}
  	}
docs: Writes a single bit to the buffer.
  
  @param bit
  0 or 1
  @throws EncodingException
  if the input is neither 0 nor 1.