Package okio
Class GzipSink
- java.lang.Object
-
- okio.GzipSink
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,Sink
public final class GzipSink extends Object implements Sink
A sink that uses GZIP to compress written data to another sink.Sync flush
Aggressive flushing of this stream may result in reduced compression. Each call toflush()immediately compresses all currently-buffered data; this early compression may be less effective than compression performed without flushing.This is equivalent to using
Deflaterwith the sync flush option. This class does not offer any partial flush mechanism. For best performance, only callflush()when application behavior requires it.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Pushes all buffered bytes to their final destination and releases the resources held by this sink.voidflush()Pushes all buffered bytes to their final destination.Timeouttimeout()Returns the timeout for this sink.voidwrite(Buffer source, long byteCount)RemovesbyteCountbytes fromsourceand appends them to this.
-
-
-
Constructor Detail
-
GzipSink
public GzipSink(Sink sink)
-
-
Method Detail
-
write
public void write(Buffer source, long byteCount) throws IOException
Description copied from interface:SinkRemovesbyteCountbytes fromsourceand appends them to this.- Specified by:
writein interfaceSink- Throws:
IOException
-
flush
public void flush() throws IOExceptionDescription copied from interface:SinkPushes all buffered bytes to their final destination.- Specified by:
flushin interfaceFlushable- Specified by:
flushin interfaceSink- Throws:
IOException- if there are any issues writing the data.
-
timeout
public Timeout timeout()
Description copied from interface:SinkReturns the timeout for this sink.
-
close
public void close() throws IOExceptionDescription copied from interface:SinkPushes all buffered bytes to their final destination and releases the resources held by this sink. It is an error to write a closed sink. It is safe to close a sink more than once.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceSink- Throws:
IOException
-
-