Class RleOutputStream

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

    public class RleOutputStream
    extends java.io.OutputStream
    The RleOutputStream handles the NuFX RLE data stream. This data stream is byte oriented. If a repeat occurs, the data stream will contain the marker byte, byte to repeat, and the number of repeats (zero based; ie, $00=1, $01=2, ... $ff=256). The default marker is $DB.
    • Constructor Summary

      Constructors 
      Constructor Description
      RleOutputStream​(java.io.OutputStream bs)
      Create an RLE output stream with the default marker byte.
      RleOutputStream​(java.io.OutputStream os, int escapeChar)
      Create an RLE output stream with the specified marker byte.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close out the data stream.
      void flush()
      Flush out any remaining data.
      void write​(int b)
      Write the next byte to the output stream.
      • Methods inherited from class java.io.OutputStream

        nullOutputStream, write, write
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RleOutputStream

        public RleOutputStream​(java.io.OutputStream bs)
        Create an RLE output stream with the default marker byte.
      • RleOutputStream

        public RleOutputStream​(java.io.OutputStream os,
                               int escapeChar)
        Create an RLE output stream with the specified marker byte.
    • Method Detail

      • write

        public void write​(int b)
                   throws java.io.IOException
        Write the next byte to the output stream.
        Specified by:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Flush out any remaining data. If we only have 1 byte and it is not the repeated byte, we can just dump that byte. Otherwise, we need to write out the escape character, the repeated byte, and the number of bytes.
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.OutputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Close out the data stream. Makes sure the repeat buffer is flushed.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.IOException