Elexis API documentation
Version 2.1.6 as of December 11 2011

ch.rgw.compress
Class HuffmanOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by ch.rgw.compress.HuffmanOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class HuffmanOutputStream
extends java.io.OutputStream

A Stream that compresses its output on the fly with the Huffmann algorithm
A Huffman tree can be provided by the caller. The tree can be declared dynamic to be recomputed regularly (for not in advance analyzable Stream with very variable data).

Author:
Gerry

Constructor Summary
HuffmanOutputStream(java.io.OutputStream sup, HuffmanTree tr, int dynamic)
          The only Constructor
 
Method Summary
 void close()
          terminate the stream: An EOF marker is written and he Stream is closed.
 void flush()
           
static java.lang.String Version()
           
 void write(int c)
           
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HuffmanOutputStream

public HuffmanOutputStream(java.io.OutputStream sup,
                           HuffmanTree tr,
                           int dynamic)
                    throws java.io.IOException
The only Constructor

Parameters:
sup - a Stream to receive the output ultimately
tree - tree a precomputed Huffman tree or null. If null, a standard tree for textual files will be used.
dynamic - if !=0: The tree will be recomputed every bytes
Throws:
java.io.IOException
Method Detail

Version

public static java.lang.String Version()

write

public void write(int c)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
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
terminate the stream: An EOF marker is written and he Stream is closed. If you don't store Informations about the length of the original data, you should always end with close(), because HuffmanInputStream can not determine the end of the compressed data.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException

Elexis API documentation
Version 2.1.6 as of December 11 2011

Copyright 2005-2011 by Gerry Weirich, Elexis