talira

I/O library for Java, Android and Kotlin Multiplatform built on ByteString and Buffer

open sourceApache-2.0free

Okio is a library that complements java.io and java.nio to make reading, storing and processing data easier. It's built around ByteString, an immutable byte sequence that encodes itself as hex, base64 and UTF-8, and Buffer, a growable byte queue that moves data between buffers without copying. Its Source and Sink streams honour timeouts on both reads and writes, and it adds a multiplatform FileSystem API. It started as part of OkHttp, which still uses it.

Problems it solves

  • read and write binary data on Android without fighting java.io streams
  • add timeouts to socket reads and writes in a JVM app
  • work with files the same way in a Kotlin Multiplatform project

Features

  • ByteString: immutable bytes with hex, base64 and UTF-8 encoding
  • Buffer: growable byte queue that moves segments without copying
  • Source and Sink streams with timeouts on reads and writes
  • multiplatform FileSystem API, with a fake file system for tests
  • Kotlin Multiplatform as well as Android and the JVM