ec.util
Class CompressingOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.util.zip.DeflaterOutputStream
ec.util.CompressingOutputStream
- public class CompressingOutputStream
- extends java.util.zip.DeflaterOutputStream
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
http://developer.java.sun.com/developer/bugParade/bugs/4255743.html
http://developer.java.sun.com/developer/bugParade/bugs/4206909.html
Fields inherited from class java.util.zip.DeflaterOutputStream |
buf, def |
Fields inherited from class java.io.FilterOutputStream |
out |
Method Summary |
void |
flush()
Insure all remaining data will be output. |
Methods inherited from class java.util.zip.DeflaterOutputStream |
close, deflate, finish, write, write |
Methods inherited from class java.io.FilterOutputStream |
write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CompressingOutputStream
public CompressingOutputStream(java.io.OutputStream output)
CompressingOutputStream
public CompressingOutputStream(java.io.OutputStream output,
int level,
boolean nowrap)
flush
public void flush()
throws java.io.IOException
- Insure all remaining data will be output.
- Throws:
java.io.IOException