Package com.webcodepro.shrinkit.io
Class RleOutputStream
java.lang.Object
java.io.OutputStream
com.webcodepro.shrinkit.io.RleOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
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
ConstructorsConstructorDescriptionCreate an RLE output stream with the default marker byte.RleOutputStream
(OutputStream os, int escapeChar) Create an RLE output stream with the specified marker byte. -
Method Summary
Methods inherited from class java.io.OutputStream
nullOutputStream, write, write
-
Constructor Details
-
RleOutputStream
Create an RLE output stream with the default marker byte. -
RleOutputStream
Create an RLE output stream with the specified marker byte.
-
-
Method Details
-
write
Write the next byte to the output stream.- Specified by:
write
in classOutputStream
- Throws:
IOException
-
flush
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 interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
Close out the data stream. Makes sure the repeat buffer is flushed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-