Class BitArrayOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    class BitArrayOutputStream
    extends java.io.OutputStream
    Output stream writing to a byte array, and capable of writing 1 bit at a time, starting from the most significant bit.
    • Field Detail

      • buffer

        private byte[] buffer
      • bytesWritten

        private int bytesWritten
      • cache

        private int cache
      • cacheMask

        private int cacheMask
    • Constructor Detail

      • BitArrayOutputStream

        BitArrayOutputStream()
      • BitArrayOutputStream

        BitArrayOutputStream​(int size)
    • Method Detail

      • size

        public int size()
      • toByteArray

        public byte[] toByteArray()
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
      • flush

        public void flush()
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.OutputStream
      • write

        public void write​(int b)
        Specified by:
        write in class java.io.OutputStream
      • writeBit

        public void writeBit​(int bit)
      • getBitsAvailableInCurrentByte

        public int getBitsAvailableInCurrentByte()
      • writeByte

        private void writeByte​(int b)