BufferedSource

interface BufferedSource : Source

A source that keeps a buffer internally so that callers can do small reads without a performance penalty. It also allows clients to read ahead, buffering as much as necessary before consuming input.

interface BufferedSource : Source, ReadableByteChannel

Functions

close
Link copied to clipboard
common
abstract override fun close()
Closes this source and releases the resources held by this source.
abstract override fun close()
Closes this source and releases the resources held by this source.
exhausted
Link copied to clipboard
common
abstract fun exhausted(): Boolean
Returns true if there are no more bytes in this source.
abstract fun exhausted(): Boolean
indexOf
Link copied to clipboard
common
abstract fun indexOf(b: Byte): Long
Equivalent to indexOf(b, 0).
abstract fun indexOf(b: Byte): Long
common
abstract fun indexOf(bytes: ByteString): Long
Equivalent to indexOf(bytes, 0).
abstract fun indexOf(bytes: ByteString): Long
common
abstract fun indexOf(b: Byte, fromIndex: Long): Long
Returns the index of the first b in the buffer at or after fromIndex.
abstract fun indexOf(b: Byte, fromIndex: Long): Long
common
abstract fun indexOf(bytes: ByteString, fromIndex: Long): Long
Returns the index of the first match for bytes in the buffer at or after fromIndex.
abstract fun indexOf(bytes: ByteString, fromIndex: Long): Long
common
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.
abstract fun indexOf(b: Byte, fromIndex: Long, toIndex: Long): Long
indexOfElement
Link copied to clipboard
common
abstract fun indexOfElement(targetBytes: ByteString): Long
abstract fun indexOfElement(targetBytes: ByteString): Long
common
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.
abstract fun indexOfElement(targetBytes: ByteString, fromIndex: Long): Long
inputStream
Link copied to clipboard
abstract fun inputStream(): InputStream
Returns an input stream that reads from this source.
isOpen
Link copied to clipboard
abstract fun isOpen(): Boolean
peek
Link copied to clipboard
common
abstract fun peek(): BufferedSource
Returns a new BufferedSource that can read data from this BufferedSource without consuming it.
abstract fun peek(): BufferedSource
rangeEquals
Link copied to clipboard
common
abstract fun rangeEquals(offset: Long, bytes: ByteString): Boolean
Returns true if the bytes at offset in this source equal bytes.
abstract fun rangeEquals(offset: Long, bytes: ByteString): Boolean
common
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.
abstract fun rangeEquals(offset: Long, bytes: ByteString, bytesOffset: Int, byteCount: Int): Boolean
read
Link copied to clipboard
abstract fun read(p0: ByteBuffer): Int
common
abstract fun read(sink: ByteArray): Int
Removes up to sink.length bytes from this and copies them into sink.
abstract fun read(sink: ByteArray): Int
common
abstract fun read(sink: Buffer, byteCount: Long): Long
Removes at least 1, and up to byteCount bytes from this and appends them to sink.
abstract fun read(sink: Buffer, byteCount: Long): Long
Removes at least 1, and up to byteCount bytes from this and appends them to sink.
common
abstract fun read(sink: ByteArray, offset: Int, byteCount: Int): Int
Removes up to byteCount bytes from this and copies them into sink at offset.
abstract fun read(sink: ByteArray, offset: Int, byteCount: Int): Int
readAll
Link copied to clipboard
common
abstract fun readAll(sink: Sink): Long
Removes all bytes from this and appends them to sink.
abstract fun readAll(sink: Sink): Long
readByte
Link copied to clipboard
common
abstract fun readByte(): Byte
Removes a byte from this source and returns it.
abstract fun readByte(): Byte
readByteArray
Link copied to clipboard
common
abstract fun readByteArray(): ByteArray
Removes all bytes from this and returns them as a byte array.
abstract fun readByteArray(): ByteArray
common
abstract fun readByteArray(byteCount: Long): ByteArray
Removes byteCount bytes from this and returns them as a byte array.
abstract fun readByteArray(byteCount: Long): ByteArray
readByteString
Link copied to clipboard
common
abstract fun readByteString(): ByteString
Removes all bytes from this and returns them as a byte string.
abstract fun readByteString(): ByteString
common
abstract fun readByteString(byteCount: Long): ByteString
Removes byteCount bytes from this and returns them as a byte string.
abstract fun readByteString(byteCount: Long): ByteString
readDecimalLong
Link copied to clipboard
common
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 '-').
abstract fun readDecimalLong(): Long
readFully
Link copied to clipboard
common
abstract fun readFully(sink: ByteArray)
Removes exactly sink.length bytes from this and copies them into sink.
abstract fun readFully(sink: ByteArray)
common
abstract fun readFully(sink: Buffer, byteCount: Long)
Removes exactly byteCount bytes from this and appends them to sink.
abstract fun readFully(sink: Buffer, byteCount: Long)
readHexadecimalUnsignedLong
Link copied to clipboard
common
abstract fun readHexadecimalUnsignedLong(): Long
Reads a long form this source in hexadecimal form (i.e., as a string in base 16).
abstract fun readHexadecimalUnsignedLong(): Long
readInt
Link copied to clipboard
common
abstract fun readInt(): Int
Removes four bytes from this source and returns a big-endian int.
abstract fun readInt(): Int
readIntLe
Link copied to clipboard
common
abstract fun readIntLe(): Int
Removes four bytes from this source and returns a little-endian int.
abstract fun readIntLe(): Int
readLong
Link copied to clipboard
common
abstract fun readLong(): Long
Removes eight bytes from this source and returns a big-endian long.
abstract fun readLong(): Long
readLongLe
Link copied to clipboard
common
abstract fun readLongLe(): Long
Removes eight bytes from this source and returns a little-endian long.
abstract fun readLongLe(): Long
readShort
Link copied to clipboard
common
abstract fun readShort(): Short
Removes two bytes from this source and returns a big-endian short.
abstract fun readShort(): Short
readShortLe
Link copied to clipboard
common
abstract fun readShortLe(): Short
Removes two bytes from this source and returns a little-endian short.
abstract fun readShortLe(): Short
readString
Link copied to clipboard
abstract fun readString(charset: Charset): String
Removes all bytes from this, decodes them as charset, and returns the string.
abstract fun readString(byteCount: Long, charset: Charset): String
Removes byteCount bytes from this, decodes them as charset, and returns the string.
readUtf8
Link copied to clipboard
common
abstract fun readUtf8(): String
Removes all bytes from this, decodes them as UTF-8, and returns the string.
abstract fun readUtf8(): String
common
abstract fun readUtf8(byteCount: Long): String
Removes byteCount bytes from this, decodes them as UTF-8, and returns the string.
abstract fun readUtf8(byteCount: Long): String
readUtf8CodePoint
Link copied to clipboard
common
abstract fun readUtf8CodePoint(): Int
Removes and returns a single UTF-8 code point, reading between 1 and 4 bytes as necessary.
abstract fun readUtf8CodePoint(): Int
readUtf8Line
Link copied to clipboard
common
abstract fun readUtf8Line(): String?
Removes and returns characters up to but not including the next line break.
abstract fun readUtf8Line(): String?
readUtf8LineStrict
Link copied to clipboard
common
abstract fun readUtf8LineStrict(): String
Removes and returns characters up to but not including the next line break.
abstract fun readUtf8LineStrict(): String
common
abstract fun readUtf8LineStrict(limit: Long): String
Like readUtf8LineStrict, except this allows the caller to specify the longest allowed match.
abstract fun readUtf8LineStrict(limit: Long): String
request
Link copied to clipboard
common
abstract fun request(byteCount: Long): Boolean
Returns true when the buffer contains at least byteCount bytes, expanding it as necessary.
abstract fun request(byteCount: Long): Boolean
require
Link copied to clipboard
common
abstract fun require(byteCount: Long)
Returns when the buffer contains at least byteCount bytes.
abstract fun require(byteCount: Long)
select
Link copied to clipboard
common
abstract fun select(options: Options): Int
Finds the first string in options that is a prefix of this buffer, consumes it from this buffer, and returns its index.
abstract fun select(options: Options): Int
skip
Link copied to clipboard
common
abstract fun skip(byteCount: Long)
Reads and discards byteCount bytes from this source.
abstract fun skip(byteCount: Long)
timeout
Link copied to clipboard
common
abstract fun timeout(): Timeout
Returns the timeout for this source.
abstract fun timeout(): Timeout
Returns the timeout for this source.

Properties

buffer
Link copied to clipboard
abstract val buffer: Buffer
This source's internal buffer.
abstract val buffer: Buffer

Inheritors

Buffer
Link copied to clipboard