BufferedSink

expect sealed interface BufferedSink : Sink

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

Inheritors

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

Inheritors

actual interface BufferedSink : Sink

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

Inheritors

Properties

Link copied to clipboard
expect abstract val buffer: Buffer

This sink's internal buffer.

actual abstract val buffer: Buffer

This sink's internal buffer.

actual abstract val buffer: Buffer

This sink's internal buffer.

Link copied to clipboard
abstract val isOpen: Boolean

Functions

Link copied to clipboard

Returns a new sink that buffers writes to this. The returned sink will batch writes to this. Use this wherever you write to a sink to get an ergonomic and efficient access to data.

Link copied to clipboard

Returns a sink that uses cipher to encrypt or decrypt this.

Link copied to clipboard
expect abstract override fun close()

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.

actual abstract override fun close()

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.

actual abstract override fun close()

Closes this object and releases the resources it holds. It is an error to use an object after it has been closed. It is safe to close an object more than once.

Link copied to clipboard
inline fun Sink.deflate(deflater: Deflater = Deflater()): DeflaterSink

Returns an DeflaterSink that DEFLATE-compresses data to this Sink while writing.

Link copied to clipboard
expect abstract fun emit(): BufferedSink

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.

actual abstract fun emit(): BufferedSink

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.

actual abstract fun emit(): BufferedSink

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.

Link copied to clipboard
expect abstract fun emitCompleteSegments(): BufferedSink

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.

actual abstract fun emitCompleteSegments(): BufferedSink

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.

actual abstract fun emitCompleteSegments(): BufferedSink

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.

Link copied to clipboard
expect abstract override fun 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.

actual abstract override fun flush()

Pushes all buffered bytes to their final destination.

actual abstract fun flush()

Pushes all buffered bytes to their final destination.

Link copied to clipboard
inline fun Sink.gzip(): GzipSink

Returns a GzipSink that gzip-compresses to this Sink while writing.

Link copied to clipboard

Returns a sink that uses digest to hash this.

Returns a sink that uses mac to hash this.

Link copied to clipboard
abstract fun outputStream(): OutputStream

Returns an output stream that writes to this sink.

Link copied to clipboard
expect abstract fun timeout(): Timeout

Returns the timeout for this sink.

actual abstract fun timeout(): Timeout

Returns the timeout for this sink.

actual abstract fun timeout(): Timeout

Returns the timeout for this sink.

Link copied to clipboard
abstract fun utf8Appendable(): Appendable

Returns an appendable that encodes strings as UTF-8 and writes them to this sink.

write
Link copied to clipboard
expect abstract fun write(source: ByteArray): BufferedSink

Like OutputStream.write, this writes a complete byte array to this sink.

expect abstract fun write(byteString: ByteString): BufferedSink
expect abstract fun write(byteString: ByteString, offset: Int, byteCount: Int): BufferedSink

expect abstract fun write(source: Source, byteCount: Long): BufferedSink

Removes byteCount bytes from source and appends them to this sink.

expect abstract fun write(source: ByteArray, offset: Int, byteCount: Int): BufferedSink

Like OutputStream.write, this writes byteCount bytes of source, starting at offset.

expect abstract fun write(source: Buffer, byteCount: Long)

Removes byteCount bytes from source and appends them to this.

abstract fun write(p0: ByteBuffer?): Int
actual abstract fun write(byteString: ByteString): BufferedSink
actual abstract fun write(byteString: ByteString, offset: Int, byteCount: Int): BufferedSink

actual abstract fun write(source: ByteArray): BufferedSink

Like OutputStream.write, this writes a complete byte array to this sink.

actual abstract fun write(source: Source, byteCount: Long): BufferedSink

Removes byteCount bytes from source and appends them to this sink.

actual abstract fun write(source: ByteArray, offset: Int, byteCount: Int): BufferedSink

Like OutputStream.write, this writes byteCount bytes of source, starting at offset.

actual abstract fun write(source: Buffer, byteCount: Long)

Removes byteCount bytes from source and appends them to this.

actual abstract fun write(source: ByteArray): BufferedSink

Like OutputStream.write, this writes a complete byte array to this sink.

actual abstract fun write(byteString: ByteString): BufferedSink
actual abstract fun write(byteString: ByteString, offset: Int, byteCount: Int): BufferedSink

actual abstract fun write(source: Source, byteCount: Long): BufferedSink

Removes byteCount bytes from source and appends them to this sink.

actual abstract fun write(source: ByteArray, offset: Int, byteCount: Int): BufferedSink

Like OutputStream.write, this writes byteCount bytes of source, starting at offset.

actual abstract fun write(source: Buffer, byteCount: Long)

Removes byteCount bytes from source and appends them to this.

Link copied to clipboard
expect abstract fun writeAll(source: Source): Long

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.

actual abstract fun writeAll(source: Source): Long

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.

actual abstract fun writeAll(source: Source): Long

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.

Link copied to clipboard
expect abstract fun writeByte(b: Int): BufferedSink

Writes a byte to this sink.

actual abstract fun writeByte(b: Int): BufferedSink

Writes a byte to this sink.

actual abstract fun writeByte(b: Int): BufferedSink

Writes a byte to this sink.

Link copied to clipboard
expect abstract fun writeDecimalLong(v: Long): BufferedSink

Writes a long to this sink in signed decimal form (i.e., as a string in base 10).

actual abstract fun writeDecimalLong(v: Long): BufferedSink

Writes a long to this sink in signed decimal form (i.e., as a string in base 10).

actual abstract fun writeDecimalLong(v: Long): BufferedSink

Writes a long to this sink in signed decimal form (i.e., as a string in base 10).

Link copied to clipboard

Writes a long to this sink in hexadecimal form (i.e., as a string in base 16).

Writes a long to this sink in hexadecimal form (i.e., as a string in base 16).

Writes a long to this sink in hexadecimal form (i.e., as a string in base 16).

Link copied to clipboard
expect abstract fun writeInt(i: Int): BufferedSink

Writes a big-endian int to this sink using four bytes.

actual abstract fun writeInt(i: Int): BufferedSink

Writes a big-endian int to this sink using four bytes.

actual abstract fun writeInt(i: Int): BufferedSink

Writes a big-endian int to this sink using four bytes.

Link copied to clipboard
expect abstract fun writeIntLe(i: Int): BufferedSink

Writes a little-endian int to this sink using four bytes.

actual abstract fun writeIntLe(i: Int): BufferedSink

Writes a little-endian int to this sink using four bytes.

actual abstract fun writeIntLe(i: Int): BufferedSink

Writes a little-endian int to this sink using four bytes.

Link copied to clipboard
expect abstract fun writeLong(v: Long): BufferedSink

Writes a big-endian long to this sink using eight bytes.

actual abstract fun writeLong(v: Long): BufferedSink

Writes a big-endian long to this sink using eight bytes.

actual abstract fun writeLong(v: Long): BufferedSink

Writes a big-endian long to this sink using eight bytes.

Link copied to clipboard
expect abstract fun writeLongLe(v: Long): BufferedSink

Writes a little-endian long to this sink using eight bytes.

actual abstract fun writeLongLe(v: Long): BufferedSink

Writes a little-endian long to this sink using eight bytes.

actual abstract fun writeLongLe(v: Long): BufferedSink

Writes a little-endian long to this sink using eight bytes.

Link copied to clipboard
expect abstract fun writeShort(s: Int): BufferedSink

Writes a big-endian short to this sink using two bytes.

actual abstract fun writeShort(s: Int): BufferedSink

Writes a big-endian short to this sink using two bytes.

actual abstract fun writeShort(s: Int): BufferedSink

Writes a big-endian short to this sink using two bytes.

Link copied to clipboard
expect abstract fun writeShortLe(s: Int): BufferedSink

Writes a little-endian short to this sink using two bytes.

actual abstract fun writeShortLe(s: Int): BufferedSink

Writes a little-endian short to this sink using two bytes.

actual abstract fun writeShortLe(s: Int): BufferedSink

Writes a little-endian short to this sink using two bytes.

Link copied to clipboard
abstract fun writeString(string: String, charset: Charset): BufferedSink
abstract fun writeString(string: String, beginIndex: Int, endIndex: Int, charset: Charset): BufferedSink
Link copied to clipboard
expect abstract fun writeUtf8(string: String): BufferedSink

Encodes string in UTF-8 and writes it to this sink.

expect abstract fun writeUtf8(string: String, beginIndex: Int, endIndex: Int): BufferedSink

Encodes the characters at beginIndex up to endIndex from string in UTF-8 and writes it to this sink.

actual abstract fun writeUtf8(string: String): BufferedSink

Encodes string in UTF-8 and writes it to this sink.

actual abstract fun writeUtf8(string: String, beginIndex: Int, endIndex: Int): BufferedSink

Encodes the characters at beginIndex up to endIndex from string in UTF-8 and writes it to this sink.

actual abstract fun writeUtf8(string: String): BufferedSink

Encodes string in UTF-8 and writes it to this sink.

actual abstract fun writeUtf8(string: String, beginIndex: Int, endIndex: Int): BufferedSink

Encodes the characters at beginIndex up to endIndex from string in UTF-8 and writes it to this sink.

Link copied to clipboard
expect abstract fun writeUtf8CodePoint(codePoint: Int): BufferedSink

Encodes codePoint in UTF-8 and writes it to this sink.

actual abstract fun writeUtf8CodePoint(codePoint: Int): BufferedSink

Encodes codePoint in UTF-8 and writes it to this sink.

actual abstract fun writeUtf8CodePoint(codePoint: Int): BufferedSink

Encodes codePoint in UTF-8 and writes it to this sink.