Class RleOutputStream
java.lang.Object
java.io.OutputStream
org.applecommander.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 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:
writein 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:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
Close out the data stream. Makes sure the repeat buffer is flushed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-