JBBPBitOutputStream extends FilterOutputStream implements JBBPCountableBitStream { private void writeByte(int value) throws IOException { if (this.msb0) { value = JBBPUtils.reverseBitsInByte((byte) value) & 0xFF; } this.out.write(value); this.byteCounter++; } JBBPBitOutputStream(final OutputStream out);  JBBPBitOutputStream(final OutputStream out, final JBBPBitOrder order); @Override JBBPBitOrder getBitOrder(); void writeShort(final int value, final JBBPByteOrder byteOrder); void writeInt(final int value, final JBBPByteOrder byteOrder); void writeFloat(final float value, final JBBPByteOrder byteOrder); void writeLong(final long value, final JBBPByteOrder byteOrder); void writeDouble(final double value, final JBBPByteOrder byteOrder); @Override long getCounter(); @Override int getBitBuffer(); @Override int getBufferedBitsNumber(); @Override void flush(); @SuppressWarnings("NullableProblems") @Override void write(final byte[] b, final int off, final int len); @SuppressWarnings("NullableProblems") @Override void write(final byte[] b); void writeBits(final int value, final JBBPBitNumber bitNumber); void align(final long alignByteNumber); @Override void close(); @Override void write(final int value); void writeBytes(final byte[] array, final int length, final JBBPByteOrder byteOrder); @Override void resetCounter(); void writeString(final String value, final JBBPByteOrder order); void writeStringArray(final String[] value, final JBBPByteOrder order);  }
@Test public void testWriteByte() throws Exception { final ByteArrayOutputStream outBiuffer = new ByteArrayOutputStream(); final JBBPBitOutputStream out = new JBBPBitOutputStream(outBiuffer); assertEquals(0, out.getCounter()); out.write(0x12); assertEquals(1, out.getCounter()); out.flush(); assertEquals(1, out.getCounter()); assertArrayEquals(new byte[] {0x12}, outBiuffer.toByteArray()); }