- All Implemented Interfaces:
public class CompressingInputStream
- extends java.util.zip.InflaterInputStream
CompressingInputStream and CompressingOutputStream 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 CompressingInputStreams and attach them one by one to the same
underlying InputStream, throwing each away one by one. This won't work.
Instread, construct one CompressingInputStream wrapped around your
underlying InputStream and just use that.
|Fields inherited from class java.util.zip.InflaterInputStream
buf, inf, len
|Fields inherited from class java.io.FilterInputStream
available() should return the number of bytes that can be read without
running into blocking wait.
|Methods inherited from class java.util.zip.InflaterInputStream
close, fill, mark, markSupported, read, read, reset, skip
|Methods inherited from class java.io.FilterInputStream
|Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public CompressingInputStream(java.io.InputStream in)
public CompressingInputStream(java.io.InputStream in,
public int available()
- available() should return the number of bytes that can be read without
running into blocking wait. Accomplishing this feast would eventually require
to pre-inflate a huge chunk of data, so we rather opt for a more relaxed
contract (java.util.zip.InflaterInputStream does not fit the bill).
This code has been tested to work with BufferedReader.readLine();
available in class