Buffer

A collection of bytes in memory.

Moving data from one buffer to another is fast. Instead of copying bytes from one place in memory to another, this class just changes ownership of the underlying byte arrays.

This buffer grows with your data. Just like ArrayList, each buffer starts small. It consumes only the memory it needs to.

This buffer pools its byte arrays. When you allocate a byte array in Java, the runtime must zero-fill the requested array before returning it to you. Even if you're going to write over that space anyway. This class avoids zero-fill and GC churn by pooling byte arrays.

Constructors

Link copied to clipboard
expect constructor()
constructor()
constructor()

Types

Link copied to clipboard
expect class UnsafeCursor : Closeable

A handle to the underlying data in a buffer. This handle is unsafe because it does not enforce its own invariants. Instead, it assumes a careful user who has studied Okio's implementation details and their consequences.

actual class UnsafeCursor : Closeable
actual class UnsafeCursor : Closeable

Properties

Link copied to clipboard
expect open override val buffer: Buffer

This source's internal buffer.

actual open override val buffer: Buffer
actual open override val buffer: Buffer
Link copied to clipboard
expect var size: Long
@get:JvmName(name = "size")
actual var size: Long
actual var size: Long

Functions

Link copied to clipboard
open override fun buffer(): Buffer

Returns this source's internal buffer.

Link copied to clipboard

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

Returns a new source that buffers reads from source. The returned source will perform bulk reads into its in-memory buffer. Use this wherever you read a source 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

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

Link copied to clipboard
expect fun clear()

Discards all bytes in this buffer. Calling this method when you're done with a buffer will return its segments to the pool.

actual fun clear()
actual fun clear()
Link copied to clipboard
open override fun clone(): Buffer

Returns a deep copy of this buffer. This is the same as copy but allows Buffer to implement the Cloneable interface on the JVM.

close
Link copied to clipboard
abstract override fun close()

Closes this source and releases the resources held by this source. It is an error to read a closed source. It is safe to close a source more than once.

open override fun close()

Closes this source and releases the resources held by this source. It is an error to read a closed source. It is safe to close a source more than once.

open override fun close()

Closes this source and releases the resources held by this source. It is an error to read a closed source. It is safe to close a source more than once.

Link copied to clipboard

Returns the number of bytes in segments that are not writable. This is the number of bytes that can be flushed immediately to an underlying sink without harming throughput.

Link copied to clipboard
expect fun copy(): Buffer

Returns a deep copy of this buffer. The returned Buffer initially shares the underlying ByteArrays. See UnsafeCursor for more details.

actual fun copy(): Buffer
actual fun copy(): Buffer
Link copied to clipboard
expect fun copyTo(out: Buffer, offset: Long = 0): Buffer

Overload of copyTo with byteCount = size - offset, work around for https://youtrack.jetbrains.com/issue/KT-30847

expect fun copyTo(out: Buffer, offset: Long = 0, byteCount: Long): Buffer

Copy byteCount bytes from this, starting at offset, to out.

actual fun copyTo(out: Buffer, offset: Long): Buffer
actual fun copyTo(out: Buffer, offset: Long, byteCount: Long): Buffer
fun copyTo(out: OutputStream, offset: Long = 0, byteCount: Long = size - offset): Buffer

Copy byteCount bytes from this, starting at offset, to out.

actual fun copyTo(out: Buffer, offset: Long): Buffer
actual fun copyTo(out: Buffer, offset: Long, byteCount: Long): Buffer
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 open override fun emit(): Buffer

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 open override fun emit(): Buffer
actual open override fun emit(): Buffer
Link copied to clipboard
expect open override fun emitCompleteSegments(): Buffer

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 open override fun emitCompleteSegments(): Buffer
actual open override fun emitCompleteSegments(): Buffer
equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
open operator override fun equals(other: Any?): Boolean
exhausted
Link copied to clipboard
expect abstract fun exhausted(): Boolean

Returns true if there are no more bytes in this source. This will block until there are bytes to read or the source is definitely exhausted.

open override fun exhausted(): Boolean
open override fun exhausted(): Boolean
flush
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.

open override fun flush()
open override fun flush()
Link copied to clipboard
expect operator fun get(pos: Long): Byte

Returns the byte at pos.

@JvmName(name = "getByte")
actual operator fun get(pos: Long): Byte
actual operator fun get(pos: Long): Byte
Link copied to clipboard
inline fun Sink.gzip(): GzipSink

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

inline fun Source.gzip(): GzipSource

Returns a GzipSource that gzip-decompresses this Source while reading.

hashCode
Link copied to clipboard
open override fun hashCode(): Int
open override fun hashCode(): Int
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

Returns a source that uses digest to hash this.

Returns a source that uses mac to hash this.

Link copied to clipboard
expect fun hmacSha1(key: ByteString): ByteString

Returns the 160-bit SHA-1 HMAC of this buffer.

actual fun hmacSha1(key: ByteString): ByteString

Returns the 160-bit SHA-1 HMAC of this buffer.

actual fun hmacSha1(key: ByteString): ByteString

Returns the 160-bit SHA-1 HMAC of this buffer.

Link copied to clipboard
expect fun hmacSha256(key: ByteString): ByteString

Returns the 256-bit SHA-256 HMAC of this buffer.

actual fun hmacSha256(key: ByteString): ByteString

Returns the 256-bit SHA-256 HMAC of this buffer.

actual fun hmacSha256(key: ByteString): ByteString

Returns the 256-bit SHA-256 HMAC of this buffer.

Link copied to clipboard
expect fun hmacSha512(key: ByteString): ByteString

Returns the 512-bit SHA-512 HMAC of this buffer.

actual fun hmacSha512(key: ByteString): ByteString

Returns the 512-bit SHA-512 HMAC of this buffer.

actual fun hmacSha512(key: ByteString): ByteString

Returns the 512-bit SHA-512 HMAC of this buffer.

indexOf
Link copied to clipboard
expect abstract fun indexOf(b: Byte): Long

Equivalent to indexOf(b, 0).

expect abstract fun indexOf(bytes: ByteString): Long

Equivalent to indexOf(bytes, 0).

expect abstract fun indexOf(b: Byte, fromIndex: Long): Long

Returns the index of the first b in the buffer at or after fromIndex. This expands the buffer as necessary until b is found. This reads an unbounded number of bytes into the buffer. Returns -1 if the stream is exhausted before the requested byte is found.

expect abstract fun indexOf(bytes: ByteString, fromIndex: Long): Long

Returns the index of the first match for bytes in the buffer at or after fromIndex. This expands the buffer as necessary until bytes is found. This reads an unbounded number of bytes into the buffer. Returns -1 if the stream is exhausted before the requested bytes are found.

expect abstract fun indexOf(b: Byte, fromIndex: Long, toIndex: Long): Long

Returns the index of b if it is found in the range of fromIndex inclusive to toIndex exclusive. If b isn't found, or if fromIndex == toIndex, then -1 is returned.

open override fun indexOf(b: Byte): Long
open override fun indexOf(bytes: ByteString): Long
open override fun indexOf(bytes: ByteString, fromIndex: Long): Long
open override fun indexOf(b: Byte, fromIndex: Long, toIndex: Long): Long

open override fun indexOf(b: Byte, fromIndex: Long): Long

Returns the index of b in this at or beyond fromIndex, or -1 if this buffer does not contain b in that range.

open override fun indexOf(b: Byte): Long
open override fun indexOf(bytes: ByteString): Long
open override fun indexOf(b: Byte, fromIndex: Long): Long
open override fun indexOf(bytes: ByteString, fromIndex: Long): Long
open override fun indexOf(b: Byte, fromIndex: Long, toIndex: Long): Long
indexOfElement
Link copied to clipboard
expect abstract fun indexOfElement(targetBytes: ByteString): Long
expect abstract fun indexOfElement(targetBytes: ByteString, fromIndex: Long): Long

Returns the first index in this buffer that is at or after fromIndex and that contains any of the bytes in targetBytes. This expands the buffer as necessary until a target byte is found. This reads an unbounded number of bytes into the buffer. Returns -1 if the stream is exhausted before the requested byte is found.

open override fun indexOfElement(targetBytes: ByteString): Long
open override fun indexOfElement(targetBytes: ByteString, fromIndex: Long): Long
open override fun indexOfElement(targetBytes: ByteString): Long
open override fun indexOfElement(targetBytes: ByteString, fromIndex: Long): Long
Link copied to clipboard
inline fun Source.inflate(inflater: Inflater = Inflater()): InflaterSource

Returns an InflaterSource that DEFLATE-decompresses this Source while reading.

Link copied to clipboard
open override fun inputStream(): InputStream

Returns an input stream that reads from this source.

Link copied to clipboard
open override fun isOpen(): Boolean
Link copied to clipboard
expect fun md5(): ByteString
actual fun md5(): ByteString

Returns the 128-bit MD5 hash of this buffer.

actual fun md5(): ByteString
Link copied to clipboard
open override fun outputStream(): OutputStream

Returns an output stream that writes to this sink.

peek
Link copied to clipboard
expect abstract fun peek(): BufferedSource

Returns a new BufferedSource that can read data from this BufferedSource without consuming it. The returned source becomes invalid once this source is next read or closed.

open override fun peek(): BufferedSource
open override fun peek(): BufferedSource
rangeEquals
Link copied to clipboard
expect abstract fun rangeEquals(offset: Long, bytes: ByteString): Boolean

Returns true if the bytes at offset in this source equal bytes. This expands the buffer as necessary until a byte does not match, all bytes are matched, or if the stream is exhausted before enough bytes could determine a match.

expect abstract fun rangeEquals(offset: Long, bytes: ByteString, bytesOffset: Int, byteCount: Int): Boolean

Returns true if byteCount bytes at offset in this source equal bytes at bytesOffset. This expands the buffer as necessary until a byte does not match, all bytes are matched, or if the stream is exhausted before enough bytes could determine a match.

open override fun rangeEquals(offset: Long, bytes: ByteString): Boolean
open override fun rangeEquals(offset: Long, bytes: ByteString, bytesOffset: Int, byteCount: Int): Boolean
open override fun rangeEquals(offset: Long, bytes: ByteString): Boolean
open override fun rangeEquals(offset: Long, bytes: ByteString, bytesOffset: Int, byteCount: Int): Boolean
read
Link copied to clipboard
expect abstract fun read(sink: ByteArray): Int

Removes up to sink.length bytes from this and copies them into sink. Returns the number of bytes read, or -1 if this source is exhausted.

expect abstract fun read(sink: ByteArray, offset: Int, byteCount: Int): Int

Removes up to byteCount bytes from this and copies them into sink at offset. Returns the number of bytes read, or -1 if this source is exhausted.

abstract fun read(sink: Buffer, byteCount: Long): Long

Removes at least 1, and up to byteCount bytes from this and appends them to sink. Returns the number of bytes read, or -1 if this source is exhausted.

open override fun read(sink: ByteBuffer): Int
open override fun read(sink: ByteArray): Int
open override fun read(sink: ByteArray, offset: Int, byteCount: Int): Int

open override fun read(sink: Buffer, byteCount: Long): Long

Removes at least 1, and up to byteCount bytes from this and appends them to sink. Returns the number of bytes read, or -1 if this source is exhausted.

open override fun read(sink: ByteArray): Int
open override fun read(sink: ByteArray, offset: Int, byteCount: Int): Int

open override fun read(sink: Buffer, byteCount: Long): Long

Removes at least 1, and up to byteCount bytes from this and appends them to sink. Returns the number of bytes read, or -1 if this source is exhausted.

readAll
Link copied to clipboard
expect abstract fun readAll(sink: Sink): Long

Removes all bytes from this and appends them to sink. Returns the total number of bytes written to sink which will be 0 if this is exhausted.

open override fun readAll(sink: Sink): Long
open override fun readAll(sink: Sink): Long
Link copied to clipboard
expect fun readAndWriteUnsafe(unsafeCursor: Buffer.UnsafeCursor = DEFAULT__new_UnsafeCursor): Buffer.UnsafeCursor
readByte
Link copied to clipboard
expect abstract fun readByte(): Byte

Removes a byte from this source and returns it.

open override fun readByte(): Byte
open override fun readByte(): Byte
readByteArray
Link copied to clipboard
expect abstract fun readByteArray(): ByteArray

Removes all bytes from this and returns them as a byte array.

expect abstract fun readByteArray(byteCount: Long): ByteArray

Removes byteCount bytes from this and returns them as a byte array.

open override fun readByteArray(): ByteArray
open override fun readByteArray(byteCount: Long): ByteArray
open override fun readByteArray(): ByteArray
open override fun readByteArray(byteCount: Long): ByteArray
readByteString
Link copied to clipboard
expect abstract fun readByteString(): ByteString

Removes all bytes from this and returns them as a byte string.

expect abstract fun readByteString(byteCount: Long): ByteString

Removes byteCount bytes from this and returns them as a byte string.

open override fun readByteString(): ByteString
open override fun readByteString(byteCount: Long): ByteString
open override fun readByteString(): ByteString
open override fun readByteString(byteCount: Long): ByteString
readDecimalLong
Link copied to clipboard
expect abstract fun readDecimalLong(): Long

Reads a long from this source in signed decimal form (i.e., as a string in base 10 with optional leading '-'). This will iterate until a non-digit character is found.

open override fun readDecimalLong(): Long
open override fun readDecimalLong(): Long
Link copied to clipboard

Read and exhaust bytes from input into this.

fun readFrom(input: InputStream, byteCount: Long): Buffer

Read byteCount bytes from input into this.

readFully
Link copied to clipboard
expect abstract fun readFully(sink: ByteArray)

Removes exactly sink.length bytes from this and copies them into sink. Throws an java.io.EOFException if the requested number of bytes cannot be read.

expect abstract fun readFully(sink: Buffer, byteCount: Long)

Removes exactly byteCount bytes from this and appends them to sink. Throws an java.io.EOFException if the requested number of bytes cannot be read.

open override fun readFully(sink: ByteArray)
open override fun readFully(sink: Buffer, byteCount: Long)
open override fun readFully(sink: ByteArray)
open override fun readFully(sink: Buffer, byteCount: Long)
readHexadecimalUnsignedLong
Link copied to clipboard
expect abstract fun readHexadecimalUnsignedLong(): Long

Reads a long form this source in hexadecimal form (i.e., as a string in base 16). This will iterate until a non-hexadecimal character is found.

open override fun readHexadecimalUnsignedLong(): Long
open override fun readHexadecimalUnsignedLong(): Long
readInt
Link copied to clipboard
expect abstract fun readInt(): Int

Removes four bytes from this source and returns a big-endian int.

open override fun readInt(): Int
open override fun readInt(): Int
readIntLe
Link copied to clipboard
expect abstract fun readIntLe(): Int

Removes four bytes from this source and returns a little-endian int.

open override fun readIntLe(): Int
open override fun readIntLe(): Int
readLong
Link copied to clipboard
expect abstract fun readLong(): Long

Removes eight bytes from this source and returns a big-endian long.

open override fun readLong(): Long
open override fun readLong(): Long
readLongLe
Link copied to clipboard
expect abstract fun readLongLe(): Long

Removes eight bytes from this source and returns a little-endian long.

open override fun readLongLe(): Long
open override fun readLongLe(): Long
readShort
Link copied to clipboard
expect abstract fun readShort(): Short

Removes two bytes from this source and returns a big-endian short.

open override fun readShort(): Short
open override fun readShort(): Short
readShortLe
Link copied to clipboard
expect abstract fun readShortLe(): Short

Removes two bytes from this source and returns a little-endian short.

open override fun readShortLe(): Short
open override fun readShortLe(): Short
Link copied to clipboard
open override fun readString(charset: Charset): String

Removes all bytes from this, decodes them as charset, and returns the string.

open override fun readString(byteCount: Long, charset: Charset): String

Removes byteCount bytes from this, decodes them as charset, and returns the string.

Link copied to clipboard
expect fun readUnsafe(unsafeCursor: Buffer.UnsafeCursor = DEFAULT__new_UnsafeCursor): Buffer.UnsafeCursor
readUtf8
Link copied to clipboard
expect abstract fun readUtf8(): String

Removes all bytes from this, decodes them as UTF-8, and returns the string. Returns the empty string if this source is empty.

expect abstract fun readUtf8(byteCount: Long): String

Removes byteCount bytes from this, decodes them as UTF-8, and returns the string.

open override fun readUtf8(): String
open override fun readUtf8(byteCount: Long): String
open override fun readUtf8(): String
open override fun readUtf8(byteCount: Long): String
readUtf8CodePoint
Link copied to clipboard
expect abstract fun readUtf8CodePoint(): Int

Removes and returns a single UTF-8 code point, reading between 1 and 4 bytes as necessary.

open override fun readUtf8CodePoint(): Int
open override fun readUtf8CodePoint(): Int
readUtf8Line
Link copied to clipboard
expect abstract fun readUtf8Line(): String?

Removes and returns characters up to but not including the next line break. A line break is either "\n" or "\r\n"; these characters are not included in the result.

open override fun readUtf8Line(): String?
open override fun readUtf8Line(): String?
readUtf8LineStrict
Link copied to clipboard
expect abstract fun readUtf8LineStrict(): String

Removes and returns characters up to but not including the next line break. A line break is either "\n" or "\r\n"; these characters are not included in the result.

expect abstract fun readUtf8LineStrict(limit: Long): String

Like readUtf8LineStrict, except this allows the caller to specify the longest allowed match. Use this to protect against streams that may not include "\n" or "\r\n".

open override fun readUtf8LineStrict(): String
open override fun readUtf8LineStrict(limit: Long): String
open override fun readUtf8LineStrict(): String
open override fun readUtf8LineStrict(limit: Long): String
request
Link copied to clipboard
expect abstract fun request(byteCount: Long): Boolean

Returns true when the buffer contains at least byteCount bytes, expanding it as necessary. Returns false if the source is exhausted before the requested bytes can be read.

open override fun request(byteCount: Long): Boolean
open override fun request(byteCount: Long): Boolean
require
Link copied to clipboard
expect abstract fun require(byteCount: Long)

Returns when the buffer contains at least byteCount bytes. Throws an java.io.EOFException if the source is exhausted before the required bytes can be read.

open override fun require(byteCount: Long)
open override fun require(byteCount: Long)
select
Link copied to clipboard
expect abstract fun select(options: Options): Int

Finds the first byte string in options that is a prefix of this buffer, consumes it from this source, and returns its index. If no byte string in options is a prefix of this buffer this returns -1 and no bytes are consumed.

expect abstract fun <T : Any> select(options: TypedOptions<T>): T?

Finds the first item in options whose encoding is a prefix of this buffer, consumes it from this buffer, and returns it. If no item in options is a prefix of this source, this function returns null and no bytes are consumed.

open override fun select(options: Options): Int
open override fun <T : Any> select(options: TypedOptions<T>): T?
open override fun select(options: Options): Int
open override fun <T : Any> select(options: TypedOptions<T>): T?
Link copied to clipboard
expect fun sha1(): ByteString
actual fun sha1(): ByteString

Returns the 160-bit SHA-1 hash of this buffer.

actual fun sha1(): ByteString
Link copied to clipboard
expect fun sha256(): ByteString
actual fun sha256(): ByteString

Returns the 256-bit SHA-256 hash of this buffer.

actual fun sha256(): ByteString
Link copied to clipboard
expect fun sha512(): ByteString
actual fun sha512(): ByteString

Returns the 512-bit SHA-512 hash of this buffer.

actual fun sha512(): ByteString
Link copied to clipboard
expect open override fun skip(byteCount: Long)

Discards byteCount bytes from the head of this buffer.

actual open override fun skip(byteCount: Long)
actual open override fun skip(byteCount: Long)
Link copied to clipboard
expect fun snapshot(): ByteString

Returns an immutable copy of this buffer as a byte string.

expect fun snapshot(byteCount: Int): ByteString

Returns an immutable copy of the first byteCount bytes of this buffer as a byte string.

actual fun snapshot(): ByteString
actual fun snapshot(byteCount: Int): ByteString
actual fun snapshot(): ByteString
actual fun snapshot(byteCount: Int): ByteString
timeout
Link copied to clipboard
abstract fun timeout(): Timeout

Returns the timeout for this source.

open override fun timeout(): Timeout

Returns the timeout for this source.

open override fun timeout(): Timeout

Returns the timeout for this source.

toString
Link copied to clipboard
open override fun toString(): String

Returns a human-readable string that describes the contents of this buffer. Typically this is a string like [text=Hello] or [hex=0000ffff].

open override fun toString(): String

Returns a human-readable string that describes the contents of this buffer. Typically this is a string like [text=Hello] or [hex=0000ffff].

Link copied to clipboard
expect open override fun write(source: ByteArray): Buffer

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

expect open override fun write(byteString: ByteString): Buffer
expect open override fun write(byteString: ByteString, offset: Int, byteCount: Int): Buffer

expect open override fun write(source: Source, byteCount: Long): Buffer

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

expect open override fun write(source: ByteArray, offset: Int, byteCount: Int): Buffer

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.

open override fun write(source: ByteBuffer): Int
actual open override fun write(source: ByteArray): Buffer
actual open override fun write(byteString: ByteString): Buffer
open override fun write(source: Buffer, byteCount: Long)
actual open override fun write(source: Source, byteCount: Long): Buffer
actual open override fun write(source: ByteArray, offset: Int, byteCount: Int): Buffer
actual open override fun write(byteString: ByteString, offset: Int, byteCount: Int): Buffer
actual open override fun write(source: ByteArray): Buffer
actual open override fun write(byteString: ByteString): Buffer
open override fun write(source: Buffer, byteCount: Long)
actual open override fun write(source: Source, byteCount: Long): Buffer
actual open override fun write(source: ByteArray, offset: Int, byteCount: Int): Buffer
actual open override fun write(byteString: ByteString, offset: Int, byteCount: Int): Buffer
writeAll
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.

open override fun writeAll(source: Source): Long
open override fun writeAll(source: Source): Long
Link copied to clipboard
expect open override fun writeByte(b: Int): Buffer

Writes a byte to this sink.

actual open override fun writeByte(b: Int): Buffer
actual open override fun writeByte(b: Int): Buffer
Link copied to clipboard
expect open override fun writeDecimalLong(v: Long): Buffer

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

actual open override fun writeDecimalLong(v: Long): Buffer
actual open override fun writeDecimalLong(v: Long): Buffer
Link copied to clipboard
expect open override fun writeHexadecimalUnsignedLong(v: Long): Buffer

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

actual open override fun writeHexadecimalUnsignedLong(v: Long): Buffer
actual open override fun writeHexadecimalUnsignedLong(v: Long): Buffer
Link copied to clipboard
expect open override fun writeInt(i: Int): Buffer

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

actual open override fun writeInt(i: Int): Buffer
actual open override fun writeInt(i: Int): Buffer
Link copied to clipboard
expect open override fun writeIntLe(i: Int): Buffer

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

actual open override fun writeIntLe(i: Int): Buffer
actual open override fun writeIntLe(i: Int): Buffer
Link copied to clipboard
expect open override fun writeLong(v: Long): Buffer

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

actual open override fun writeLong(v: Long): Buffer
actual open override fun writeLong(v: Long): Buffer
Link copied to clipboard
expect open override fun writeLongLe(v: Long): Buffer

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

actual open override fun writeLongLe(v: Long): Buffer
actual open override fun writeLongLe(v: Long): Buffer
Link copied to clipboard
expect open override fun writeShort(s: Int): Buffer

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

actual open override fun writeShort(s: Int): Buffer
actual open override fun writeShort(s: Int): Buffer
Link copied to clipboard
expect open override fun writeShortLe(s: Int): Buffer

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

actual open override fun writeShortLe(s: Int): Buffer
actual open override fun writeShortLe(s: Int): Buffer
Link copied to clipboard
open override fun writeString(string: String, charset: Charset): Buffer
open override fun writeString(string: String, beginIndex: Int, endIndex: Int, charset: Charset): Buffer
Link copied to clipboard
fun writeTo(out: OutputStream, byteCount: Long = size): Buffer

Write byteCount bytes from this to out.

Link copied to clipboard
expect open override fun writeUtf8(string: String): Buffer

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

expect open override fun writeUtf8(string: String, beginIndex: Int, endIndex: Int): Buffer

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

actual open override fun writeUtf8(string: String): Buffer
actual open override fun writeUtf8(string: String, beginIndex: Int, endIndex: Int): Buffer
actual open override fun writeUtf8(string: String): Buffer
actual open override fun writeUtf8(string: String, beginIndex: Int, endIndex: Int): Buffer
Link copied to clipboard
expect open override fun writeUtf8CodePoint(codePoint: Int): Buffer

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

actual open override fun writeUtf8CodePoint(codePoint: Int): Buffer
actual open override fun writeUtf8CodePoint(codePoint: Int): Buffer