Skip to content

okio / okio / BufferedSink

BufferedSink

(js, jvm, native) interface BufferedSink :Sink

A sink that keeps a buffer internally so that callers can do small writes without a performance penalty.

Properties

Name Summary
(js, jvm, native) buffer This sink’s internal buffer.abstract val buffer:Buffer

Functions

Name Summary
(jvm) buffer Returns this sink’s internal buffer.abstract fun ~~buffer~~():Buffer
(js, jvm, native) emit Writes all buffered data to the underlying sink, if one exists. Like flush, but weaker. Call this before this buffered sink goes out of scope so that its data can reach its destination.abstract fun emit():BufferedSink
(js, jvm, native) emitCompleteSegments Writes complete segments to the underlying sink, if one exists. Like flush, but weaker. Use this to limit the memory held in the buffer to a single segment. Typically application code will not need to call this: it is only necessary when application code writes directly to this sink’s buffer.abstract fun emitCompleteSegments():BufferedSink
(js, jvm) flush Writes all buffered data to the underlying sink, if one exists. Then that sink is recursively flushed which pushes data as far as possible towards its ultimate destination. Typically that destination is a network socket or file.abstract fun flush():Unit
(jvm) outputStream Returns an output stream that writes to this sink.abstract fun outputStream():OutputStream
(js, jvm, native) write abstract fun write(byteString:ByteString):BufferedSink
abstract fun write(byteString:ByteString, offset:Int, byteCount:Int):BufferedSink
Like OutputStream.write, this writes a complete byte array to this sink.abstract fun write(source:ByteArray):BufferedSink
Like OutputStream.write, this writes byteCount bytes of source, starting at offset.abstract fun write(source:ByteArray, offset:Int, byteCount:Int):BufferedSink
Removes byteCount bytes from source and appends them to this sink.abstract fun write(source:Source, byteCount:Long):BufferedSink
(js, jvm, native) writeAll Removes all bytes from source and appends them to this sink. Returns the number of bytes read which will be 0 if source is exhausted.abstract fun writeAll(source:Source):Long
(js, jvm, native) writeByte Writes a byte to this sink.abstract fun writeByte(b:Int):BufferedSink
(js, jvm, native) writeDecimalLong Writes a long to this sink in signed decimal form (i.e., as a string in base 10).abstract fun writeDecimalLong(v:Long):BufferedSink
(js, jvm, native) writeHexadecimalUnsignedLong Writes a long to this sink in hexadecimal form (i.e., as a string in base 16).abstract fun writeHexadecimalUnsignedLong(v:Long):BufferedSink
(js, jvm, native) writeInt Writes a big-endian int to this sink using four bytes.abstract fun writeInt(i:Int):BufferedSink
(js, jvm, native) writeIntLe Writes a little-endian int to this sink using four bytes.abstract fun writeIntLe(i:Int):BufferedSink
(js, jvm, native) writeLong Writes a big-endian long to this sink using eight bytes.abstract fun writeLong(v:Long):BufferedSink
(js, jvm, native) writeLongLe Writes a little-endian long to this sink using eight bytes.abstract fun writeLongLe(v:Long):BufferedSink
(js, jvm, native) writeShort Writes a big-endian short to this sink using two bytes.abstract fun writeShort(s:Int):BufferedSink
(js, jvm, native) writeShortLe Writes a little-endian short to this sink using two bytes.abstract fun writeShortLe(s:Int):BufferedSink
(jvm) writeString abstract fun writeString(string:String, charset:Charset):BufferedSink
abstract fun writeString(string:String, beginIndex:Int, endIndex:Int, charset:Charset):BufferedSink
(js, jvm, native) writeUtf8 Encodes string in UTF-8 and writes it to this sink.abstract fun writeUtf8(string:String):BufferedSink
Encodes the characters at beginIndex up to endIndex from string in UTF-8 and writes it to this sink.abstract fun writeUtf8(string:String, beginIndex:Int, endIndex:Int):BufferedSink
(js, jvm, native) writeUtf8CodePoint Encodes codePoint in UTF-8 and writes it to this sink.abstract fun writeUtf8CodePoint(codePoint:Int):BufferedSink

Extension Functions

Name Summary
(jvm) deflate Returns an DeflaterSink that DEFLATE-compresses data to this Sink while writing.funSink.deflate(deflater:Deflater= Deflater()):DeflaterSink
(jvm) gzip Returns a GzipSink that gzip-compresses to this Sink while writing.funSink.gzip():GzipSink

Inheritors

Name Summary
(js, jvm, native) Buffer A collection of bytes in memory.class Buffer :BufferedSource,BufferedSink