Tutorial by Examples

Download the latest JAR or grab via Maven: <dependency> <groupId>com.squareup.okio</groupId> <artifactId>okio</artifactId> <version>1.12.0</version> </dependency> or Gradle: compile 'com.squareup.okio:okio:1.12.0'
Decoding the chunks of a PNG file demonstrates Okio in practice. private static final ByteString PNG_HEADER = ByteString.decodeHex("89504e470d0a1a0a"); public void decodePng(InputStream in) throws IOException { try (BufferedSource pngSource = Okio.buffer(Okio.source(in))) { Byt...
ByteStrings and Buffers Okio is built around two types that pack a lot of capability into a straightforward API: ByteString is an immutable sequence of bytes. For character data, String is fundamental. ByteString is String's long-lost brother, making it easy to treat binary data as a value. This c...

Page 1 of 1