Package com.webcodepro.shrinkit.io
Class RleOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- com.webcodepro.shrinkit.io.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.
-
-
-
Method Detail
-
write
public void write(int b) throws java.io.IOException
Write the next byte to the output stream.- Specified by:
write
in classjava.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 interfacejava.io.Flushable
- Overrides:
flush
in classjava.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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.OutputStream
- Throws:
java.io.IOException
-
-