fr.up7.info
Class RLEOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by fr.up7.info.RLEOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class RLEOutputStream
extends FilterOutputStream

A RLEOutputStream implements a stream filter to compress data and physically write it using a RLE format. The format is such that any too long running subsequence of the same single letter in the original data is encoded as the length of the run and the letter. As aaaabbdeaaa could simply be encoded as *4abbde*3a.

Since:
1.4
Version:
0.1 (10/2005)
Author:
Jean-Baptiste Yunès
See Also:
FilterOutputStream

Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
RLEOutputStream(OutputStream os)
          Constructs a compressing output stream from a given output stream.
 
Method Summary
 void close()
          Closes the stream.
 void flush()
          Flushes this output stream, forces any buffered data to be written
 int offset()
          Gets the length of the compressed data stream.
 void write(int b)
          Writes a byte of uncompressed data.
 
Methods inherited from class java.io.FilterOutputStream
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(OutputStream os)
                throws fr.up7.info.RLEHeaderException
Constructs a compressing output stream from a given output stream.

Parameters:
os - the underlying output stream.
Throws:
RLEMissingHeaderException - if no header is found in the file
RLEUnknownHeaderException - if an unknown header is found.
fr.up7.info.RLEHeaderException
Method Detail

write

public void write(int b)
           throws IOException
Writes a byte of uncompressed data.

Overrides:
write in class FilterOutputStream
Throws:
IOException - if an I/O error has occured.
See Also:
FilterOutputStream.out

close

public void close()
           throws IOException
Closes the stream.

Specified by:
close in interface Closeable
Overrides:
close in class FilterOutputStream
Throws:
IOException - if an I/O error has occured.
See Also:
FilterOutputStream.out

flush

public void flush()
           throws IOException
Flushes this output stream, forces any buffered data to be written

Specified by:
flush in interface Flushable
Overrides:
flush in class FilterOutputStream
Throws:
IOException - if an I/O error has occured

offset

public int offset()
Gets the length of the compressed data stream.

Returns:
the length of the data stream