public byte[] getBytes() throws IOException {
        if (this.bitOffset % 8 != 0) {
            throw new IOException(
                    "BitWriter:Bytes, Cannot get the current bytes because the last byte is not written completely.");
        }

        int retByteLength = this.bitOffset / 8;
        return Arrays.copyOfRange(bitSet.toByteArray(), 0, retByteLength);
    }
Gets a copy byte array which contains the current written byte.
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/onenote/fsshttpb/util/BitWriter.java