Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to okio

Introduction to okio

okio is a library for A modern I/O API for Java, maintained by Square, Inc.

I have talked about okio in general; the history and basics of it.

* square/okio
https://github.com/square/okio/

* Droidcon Montreal Jake Wharton - A Few Ok Libraries
https://www.youtube.com/watch?v=WvyScM_S88c

* Buffering data with Okio
https://corner.squareup.com/2014/04/okio.html

* OkHttpの依存ライブラリのOkioでチェックサム算出 - 初老のボケ防止日記
http://osa030.hatenablog.com/entry/2015/05/21/124931

* Y.A.M の 雑記帳: 4月 2015
http://y-anz-m.blogspot.jp/2015_04_01_archive.html

* Droidcon Montreal まとめ - hydrakecat’s blog
http://hydrakecat.hatenablog.jp/entry/2015/05/24/Droidcon_Montreal_%E3%81%BE%E3%81%A8%E3%82%81

* No beer emoji for java.io.Reader
https://publicobject.com/2015/05/16/no-beer-emoji-for-java-io-reader/

* 046: okJesse – A deep discussion on okHttp, okio and Retrofit – Fragmented
http://fragmentedpodcast.com/episodes/46/

Shohei Kawano

July 22, 2016
Tweet

More Decks by Shohei Kawano

Other Decks in Programming

Transcript

  1. okio • History of okio • Basics of okio •

    etc
 
 No sample code or project; all I know from research of okio.
  2. History of okio at glance 1. Square team made “OkHttp”;

    HTTP + SPDY supported client for Android. 2. Processing HTTP using java.io and java.nio inside OkHttp was painful. 3. Square team implemented efficient way of processing data for OkHttp, and exported it as another library, called “okio”.
  3. History of okio at glance 1. Square team made “OkHttp”;

    HTTP + SPDY supported client for Android. 2. Processing HTTP using java.io and java.nio inside OkHttp was painful. 3. Square team implemented efficient way of processing data for OkHttp, and exported it as another library, called “okio”.
  4. java.io and java.nio • InputStream is fundamentally for reading data

    • Decorators • DataInputStream for primitive values • BufferedInputStream / BufferedReader for buffering • InputStreamReader for strings • When processing, fixed-sized Byte[] is passed and created • Hard to program efficiently..! so okie was made. https://www.youtube.com/watch?v=WvyScM_S88c
  5. Now okio is used in many Square libraries:
 • OkHttp

    • Retrofit • Moshi • Wire
 
 and maybe more?
  6. Basics of okio • 2014-04-08 Initial Public Release (0.5.0) •

    Latest Version: 1.9.0 • Imported from OkHttp • “Making it much easier to access, store, and process your data.” • Complement of java.io and java.nio https://github.com/square/okio
  7. Basics of okio • Naming Convention: java.io, java.nio => okio.

    • ByteString and Buffer
 ByteString: Binary data as a value
 Buffer: Mutable sequence of bytes • Source and Sink
 Source: InputStream
 Sink: OutputStream https://github.com/square/okio
  8. ByteString ByteString byteString = ByteString.of(bytes); String data = byteString.utf8();
 byteString.base64();


    byteString.hex();
 byteString.md5();
 byteString.sha1();
 byteString.sha256();
  9. blackhole • Added 2 weeks ago; Available from next ver.

    https://github.com/square/okio/issues/229