public interface Sink extends java.io.Closeable, java.io.Flushable
Sinks are easy to test: just use a
Buffer in your tests, and
read from it to confirm it received the data that was expected.
OutputStream requires multiple layers when emitted data is
DataOutputStream for primitive values, a
BufferedOutputStream for buffering, and
charset encoding. This class uses
BufferedSink for all of the above.
Sink is also easier to layer: there is no single-byte write method that is awkward to implement efficiently.
Okio.sink(java.io.OutputStream)to adapt an
OutputStreamto a sink. Use
BufferedSink.outputStream()to adapt a sink to an
|Modifier and Type||Method and Description|
Pushes all buffered bytes to their final destination and releases the resources held by this sink.
Pushes all buffered bytes to their final destination.
Returns the timeout for this sink.
void write(Buffer source, long byteCount) throws java.io.IOException
sourceand appends them to this.
void flush() throws java.io.IOException
void close() throws java.io.IOException
Copyright © 2018. All Rights Reserved.