Package-level declarations

Types

Link copied to clipboard
open class AsyncTimeout : Timeout

This timeout uses a background thread to take action exactly when the timeout occurs. Use this to implement timeouts where they aren't supported natively, such as to sockets that are blocked on writing.

Link copied to clipboard

A collection of bytes in memory.

Link copied to clipboard
expect sealed interface BufferedSink : Sink

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

actual interface BufferedSink : Sink
Link copied to clipboard
expect sealed 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.

actual interface BufferedSource : Source
Link copied to clipboard
actual open class ByteString : Comparable<ByteString>
expect open class ByteString : Comparable<ByteString>

An immutable sequence of bytes.

actual open class ByteString : Comparable<ByteString>
Link copied to clipboard
class CipherSink(sink: BufferedSink, val cipher: Cipher) : Sink
Link copied to clipboard
class CipherSource(source: BufferedSource, val cipher: Cipher) : Source
Link copied to clipboard
expect interface Closeable
actual typealias Closeable = java.io.Closeable
actual interface Closeable
Link copied to clipboard
actual typealias Deflater = java.util.zip.Deflater
expect class Deflater(level: Int, nowrap: Boolean)
Link copied to clipboard
expect class DeflaterSink : Sink

A sink that uses DEFLATE to compress data written to another source.

Link copied to clipboard
expect open class EOFException(message: String?) : IOException
actual open class EOFException(message: String?) : IOException
Link copied to clipboard
abstract class FileHandle(val readWrite: Boolean) : Closeable

An open file for reading and writing; using either streaming and random access.

Link copied to clipboard
class FileMetadata(val isRegularFile: Boolean = false, val isDirectory: Boolean = false, val symlinkTarget: Path? = null, val size: Long? = null, val createdAtMillis: Long? = null, val lastModifiedAtMillis: Long? = null, val lastAccessedAtMillis: Long? = null, extras: Map<KClass<*>, Any> = mapOf())

Description of a file or another object referenced by a path.

Link copied to clipboard
expect class FileNotFoundException(message: String?) : IOException
actual open class FileNotFoundException(message: String?) : IOException
Link copied to clipboard
expect abstract class FileSystem

Read and write access to a hierarchical collection of files, addressed by paths. This is a natural interface to the current computer's local file system.

actual abstract class FileSystem
actual abstract class FileSystem
actual abstract class FileSystem
actual abstract class FileSystem
Link copied to clipboard
abstract class ForwardingFileSystem(val delegate: FileSystem) : FileSystem

A FileSystem that forwards calls to another, intended for subclassing.

Link copied to clipboard
abstract class ForwardingSink(val delegate: Sink) : Sink

A Sink which forwards calls to another. Useful for subclassing.

Link copied to clipboard
expect abstract class ForwardingSource(delegate: Source) : Source

A Source which forwards calls to another. Useful for subclassing.

actual abstract class ForwardingSource(val delegate: Source) : Source
actual abstract class ForwardingSource(val delegate: Source) : Source
Link copied to clipboard
open class ForwardingTimeout(var delegate: Timeout) : Timeout

A Timeout which forwards calls to another. Useful for subclassing.

Link copied to clipboard
class GzipSink(sink: Sink) : Sink

A sink that uses GZIP to compress written data to another sink.

Link copied to clipboard
class GzipSource(source: Source) : Source

A source that uses GZIP to decompress data read from another source.

Link copied to clipboard
expect class HashingSink : Sink

A sink that computes a hash of the full stream of bytes it has accepted. To use, create an instance with your preferred hash algorithm. Write all of the data to the sink and then call hash to compute the final hash value.

A sink that computes a hash of the full stream of bytes it has accepted. To use, create an instance with your preferred hash algorithm. Write all of the data to the sink and then call hash to compute the final hash value.

actual class HashingSink : Sink
Link copied to clipboard
expect class HashingSource : Source

A source that computes a hash of the full stream of bytes it has supplied. To use, create an instance with your preferred hash algorithm. Exhaust the source by reading all of its bytes and then call hash to compute the final hash value.

A source that computes a hash of the full stream of bytes it has supplied. To use, create an instance with your preferred hash algorithm. Exhaust the source by reading all of its bytes and then call hash to compute the final hash value.

actual class HashingSource : Source
Link copied to clipboard
actual typealias Inflater = java.util.zip.Inflater
expect class Inflater(nowrap: Boolean)
Link copied to clipboard
expect class InflaterSource : Source

A source that uses DEFLATE to decompress data read from another source.

Link copied to clipboard
expect open class IOException(message: String?, cause: Throwable?) : Exception
actual typealias IOException = java.io.IOException
actual open class IOException(message: String?, cause: Throwable?) : Exception
Link copied to clipboard
expect class Lock
actual typealias Lock = ReentrantLock
actual class Lock
Link copied to clipboard

An indexed set of values that may be read with BufferedSource.select.

Link copied to clipboard
expect class Path : Comparable<Path>

A hierarchical address on a file system. A path is an identifier only; a FileSystem is required to access the file that a path refers to, if any.

actual class Path : Comparable<Path>
actual class Path : Comparable<Path>
Link copied to clipboard
class Pipe(maxBufferSize: Long)

A source and a sink that are attached. The sink's output is the source's input. Typically each is accessed by its own thread: a producer thread writes data to the sink and a consumer thread reads data from the source.

Link copied to clipboard
expect class ProtocolException(message: String) : IOException
actual class ProtocolException(message: String) : IOException
Link copied to clipboard
expect interface Sink : Closeable

Receives a stream of bytes. Use this interface to write data wherever it's needed: to the network, storage, or a buffer in memory. Sinks may be layered to transform received data, such as to compress, encrypt, throttle, or add protocol framing.

actual interface Sink : Closeable, Flushable
actual interface Sink : Closeable
Link copied to clipboard
interface Source : Closeable

Supplies a stream of bytes. Use this interface to read data from wherever it's located: from the network, storage, or a buffer in memory. Sources may be layered to transform supplied data, such as to decompress, decrypt, or remove protocol framing.

Link copied to clipboard
class Throttler

Enables limiting of Source and Sink throughput. Attach to this throttler via source and sink and set the desired throughput via bytesPerSecond. Multiple Sources and Sinks can be attached to a single Throttler and they will be throttled as a group, where their combined throughput will not exceed the desired throughput. The same Source or Sink can be attached to multiple Throttlers and its throughput will not exceed the desired throughput of any of the Throttlers.

Link copied to clipboard
expect open class Timeout

A policy on how much time to spend on a task before giving up. When a task times out, it is left in an unspecified state and should be abandoned. For example, if reading from a source times out, that source should be closed and the read should be retried later. If writing to a sink times out, the same rules apply: close the sink and retry later.

actual open class Timeout
actual open class Timeout
Link copied to clipboard
class TypedOptions<T : Any>(list: List<T>, options: Options) : AbstractList<T> , RandomAccess

A list of values that may be read with BufferedSource.select.

Properties

Link copied to clipboard
val Okio: -DeprecatedOkio
Link copied to clipboard
expect val FileSystem.Companion.SYSTEM: FileSystem
Link copied to clipboard
val Utf8: -DeprecatedUtf8

Functions

Link copied to clipboard

Returns a sink that writes to file.

Link copied to clipboard
Link copied to clipboard
@JvmName(name = "blackhole")
fun blackholeSink(): Sink

Returns a sink that writes nowhere.

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
inline fun Sink.deflate(deflater: Deflater = Deflater()): DeflaterSink

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

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.

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
inline fun Source.inflate(inflater: Inflater = Inflater()): InflaterSource

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

Link copied to clipboard
fun FileSystem.openZip(zipPath: Path): FileSystem
Link copied to clipboard
fun COpaquePointer.readByteString(count: Int): ByteString

Copy count bytes from the memory at this pointer into a ByteString.

Link copied to clipboard

Returns a sink that writes to out.

Returns a sink that writes to socket. Prefer this over sink because this method honors timeouts. When the socket write times out, the socket is asynchronously closed by a watchdog thread.

fun File.sink(append: Boolean = false): Sink

Returns a sink that writes to file.

fun Path.sink(vararg options: OpenOption): Sink

Returns a sink that writes to path.

Link copied to clipboard

Returns a source that reads from file.

Returns a source that reads from in.

Returns a source that reads from socket. Prefer this over source because this method honors timeouts. When the socket read times out, the socket is asynchronously closed by a watchdog thread.

fun Path.source(vararg options: OpenOption): Source

Returns a source that reads from path.

Link copied to clipboard
inline fun <T : Closeable?, R> T.use(block: (T) -> R): R

Execute block then close this. This will be closed even if block throws.

Link copied to clipboard
@JvmName(name = "size")
fun String.utf8Size(beginIndex: Int = 0, endIndex: Int = length): Long

Returns the number of bytes used to encode the slice of string as UTF-8 when using BufferedSink.writeUtf8.

Link copied to clipboard
expect inline fun <T> Lock.withLock(action: () -> T): T
actual inline fun <T> Lock.withLock(action: () -> T): T