Package okio
Class GzipSink
java.lang.Object
okio.GzipSink
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,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 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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Pushes all buffered bytes to their final destination and releases the resources held by this sink.final Deflater
deflater()
Returns theDeflater
.void
flush()
Pushes all buffered bytes to their final destination.timeout()
Returns the timeout for this sink.void
RemovesbyteCount
bytes fromsource
and appends them to this.
-
Constructor Details
-
GzipSink
-
-
Method Details
-
write
Description copied from interface:Sink
RemovesbyteCount
bytes fromsource
and appends them to this.- Specified by:
write
in interfaceSink
- Throws:
IOException
-
flush
Description copied from interface:Sink
Pushes all buffered bytes to their final destination.- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in interfaceSink
- Throws:
IOException
-
timeout
Description copied from interface:Sink
Returns the timeout for this sink. -
close
Description copied from interface:Sink
Pushes 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceSink
- Throws:
IOException
-
deflater
Returns theDeflater
. Use it to access stats, dictionary, compression level, etc.
-