@Override
    public void write(int b) throws IOException {
        Preconditions.checkArgument(b == 0 || b == 1, "Argument must be 0 or 1");
        currentByte = currentByte << 1 | b;
        numBitsInCurrentByte++;
        if (numBitsInCurrentByte == 8) {
            output.write(currentByte);
            numBitsInCurrentByte = 0;
        }
    }
A stream where bits can be written to.

<p>Because they are written to an underlying byte stream, the end of the stream is padded with
0's up to a multiple of 8 bits. The bits are written in big endian.
indexr-common/src/main/java/io/indexr/io/BitWrappedOutputStream.java