de.enough.polish.util.zip
Class GZipOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by de.enough.polish.util.zip.GZipOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class GZipOutputStream
extends OutputStream

Generates GZIP or DEFLATE encoded input streams from an InputStream.

Copyright Enough Software 2007 - 2010

 history
        Jun 28, 2007 - Simon creation
 

Author:
Simon Schmitt, simon.schmitt@enough.de

Field Summary
static int TYPE_DEFLATE
          This constant triggers the normal deflate compression as described in rfc 1951.
static int TYPE_GZIP
          This constant triggers the gzip compression that is the same as deflate with some extra header information (see rfc 1952).
 
Constructor Summary
GZipOutputStream(OutputStream outputStream, int size, int compressionType, int plainWindowSize, int huffmanWindowSize)
           
 
Method Summary
 void close()
           
 void flush()
          It is strongly recomended NOT to call flush before close() since close() is able to handle the flushing better itself.
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_DEFLATE

public static final int TYPE_DEFLATE
This constant triggers the normal deflate compression as described in rfc 1951.

See Also:
Constant Field Values

TYPE_GZIP

public static final int TYPE_GZIP
This constant triggers the gzip compression that is the same as deflate with some extra header information (see rfc 1952).

See Also:
Constant Field Values
Constructor Detail

GZipOutputStream

public GZipOutputStream(OutputStream outputStream,
                        int size,
                        int compressionType,
                        int plainWindowSize,
                        int huffmanWindowSize)
                 throws IOException
Parameters:
outputStream - stream to write the compressed data in
size - prefered size of the internal buffer
compressionType - TYPE_GZIP or TYPE_DEFLATE
plainWindowSize - this size is important for the lz77 search. Larger values will result in better compression. Maximum is 32768.
huffmanWindowSize - this size is important for the huffmanencoding. A large value will result to a better frequency statistic and therefore to a better compression.
Throws:
IOException - might be thrown in case that the inputStream can not be read, the outputStream can not be written into or in case of wrong arguments
See Also:
TYPE_DEFLATE, TYPE_GZIP
Method Detail

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException

flush

public void flush()
           throws IOException
It is strongly recomended NOT to call flush before close() since close() is able to handle the flushing better itself.

Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

write

public void write(int b)
           throws IOException
Specified by:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException