public final class DeflaterSink extends java.lang.Object implements Sink
flush() immediately compresses all currently-buffered data;
this early compression may be less effective than compression performed
without flushing.
This is equivalent to using Deflater with the sync flush option.
This class does not offer any partial flush mechanism. For best performance,
only call flush() when application behavior requires it.
| Modifier and Type | Field and Description |
|---|---|
private boolean |
closed |
private java.util.zip.Deflater |
deflater |
private BufferedSink |
sink |
| Constructor and Description |
|---|
DeflaterSink(BufferedSink sink,
java.util.zip.Deflater deflater)
This package-private constructor shares a buffer with its trusted caller.
|
DeflaterSink(Sink sink,
java.util.zip.Deflater deflater) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Pushes all buffered bytes to their final destination and releases the
resources held by this sink.
|
private void |
deflate(boolean syncFlush) |
(package private) void |
finishDeflate() |
void |
flush()
Pushes all buffered bytes to their final destination.
|
Timeout |
timeout()
Returns the timeout for this sink.
|
java.lang.String |
toString() |
void |
write(Buffer source,
long byteCount)
Removes
byteCount bytes from source and appends them to this. |
private final BufferedSink sink
private final java.util.zip.Deflater deflater
private boolean closed
public DeflaterSink(Sink sink, java.util.zip.Deflater deflater)
DeflaterSink(BufferedSink sink, java.util.zip.Deflater deflater)
public void write(Buffer source, long byteCount) throws java.io.IOException
SinkbyteCount bytes from source and appends them to this.private void deflate(boolean syncFlush)
throws java.io.IOException
java.io.IOExceptionpublic void flush()
throws java.io.IOException
Sinkvoid finishDeflate()
throws java.io.IOException
java.io.IOExceptionpublic void close()
throws java.io.IOException
Sinkpublic Timeout timeout()
Sinkpublic java.lang.String toString()
toString in class java.lang.Object