Class CompressingOutputStream

  extended by
      extended by
          extended by
              extended by ec.util.CompressingOutputStream
All Implemented Interfaces:,

public class CompressingOutputStream

CompressingInputStream and DecompressingOutputStream allow you to perform compression on a stream, and flush it, and continue to use it. This is useful if you're planning on compressing a stream socket. Ordinarily compression does not send partial blocks across the stream for efficiency's sake. That's not good because we want to use a stream socket and the other side will just block waiting for a big chunk of data that may take a long time to show up. This simulates the Z_PARTIAL_FLUSH and Z_SYNC_FLUSH mechanisms in zlib. The code was largely stolen from the comments at

Beware that, like other compression streams, you should NOT construct multiple CompressingOutputStreams and attach them one by one to the same underlying OutputStream, throwing each away one by one. This won't work. Instread, construct one CompressingOutputStream wrapped around your underlying OutputStream and just use that.

Field Summary
Fields inherited from class
buf, def
Fields inherited from class
Constructor Summary
CompressingOutputStream( output)
CompressingOutputStream( output, int level, boolean nowrap)
Method Summary
 void flush()
          Insure all remaining data will be output.
Methods inherited from class
close, deflate, finish, write, write
Methods inherited from class
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public CompressingOutputStream( output)


public CompressingOutputStream( output,
                               int level,
                               boolean nowrap)
Method Detail


public void flush()
Insure all remaining data will be output.

Specified by:
flush in interface
flush in class