|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
net.sf.jazzlib.DeflaterOutputStream
org.hd.d.pg2k.webSvr.util.FlushableGZIPOutputStream
public class FlushableGZIPOutputStream
Substitute for GZIPOutputStream that maximises compression and has a usable flush(). This is also more careful about its output writes for efficiency, and indeed buffers them to minimise the number of write()s downstream. This is especially useful where each write() potentially has a significant cost such as an OS call, a disc write, or a network packet.
This will automatically throttle back from maximum to default compression (which usually yields nearly as good results on significantly less effort) when the system is conserving power/energy.
| Field Summary | |
|---|---|
private java.util.zip.CRC32 |
crc
|
private static int |
GZIP_MAGIC
|
private static byte[] |
header
Constant (10-byte) header array. |
private java.io.OutputStream |
os
|
private boolean |
somethingWritten
Note when input has arrived and not yet been compressed and flushed downstream. |
private static int |
TRAILER_BYTES
Length of the trailer in bytes. |
| Fields inherited from class net.sf.jazzlib.DeflaterOutputStream |
|---|
buf, def |
| Fields inherited from class java.io.FilterOutputStream |
|---|
out |
| Constructor Summary | |
|---|---|
FlushableGZIPOutputStream(java.io.OutputStream os)
Creates flush()able equivalent of GZIPOutputStream, with maximum/best compression and default output buffer size. |
|
FlushableGZIPOutputStream(java.io.OutputStream os,
int bufsize)
Creates flush()able equivalent of GZIPOutputStream, with good compression. |
|
| Method Summary | |
|---|---|
void |
close()
Flush out any remaining compressed data, add the trailer, and close the stream. |
void |
flush()
Flush any accumulated input downstream in compressed form. |
private byte[] |
generateTrailer()
Return header to write downstream. |
void |
write(byte[] buf,
int off,
int len)
All output is written via this routine. |
private void |
writeHeader()
Write header directly downstream. |
| Methods inherited from class net.sf.jazzlib.DeflaterOutputStream |
|---|
deflate, finish, 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 |
| Field Detail |
|---|
private final java.util.zip.CRC32 crc
private static final int GZIP_MAGIC
private final java.io.OutputStream os
private boolean somethingWritten
private static final byte[] header
private static final int TRAILER_BYTES
| Constructor Detail |
|---|
public FlushableGZIPOutputStream(java.io.OutputStream os)
throws java.io.IOException
os - underlying output stream; must not be null
java.io.IOException
public FlushableGZIPOutputStream(java.io.OutputStream os,
int bufsize)
throws java.io.IOException
os - underlying output stream; must not be nullbufsize - output buffer size; must be positive
java.io.IOException| Method Detail |
|---|
public void write(byte[] buf,
int off,
int len)
throws java.io.IOException
write in class net.sf.jazzlib.DeflaterOutputStreamjava.io.IOException
public void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class net.sf.jazzlib.DeflaterOutputStreamjava.io.IOException
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class net.sf.jazzlib.DeflaterOutputStreamjava.io.IOException
private void writeHeader()
throws java.io.IOException
java.io.IOExceptionprivate byte[] generateTrailer()
|
DHD Multimedia Gallery V1.57.21 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||