Kotlin Write InputStream to File Using Okio

June 19, 2018
fun copyToFile(inputStream: InputStream, outputFile: File) {
    val source = Okio.buffer(Okio.source(inputStream))
    val sink = Okio.buffer(Okio.sink(outputFile))

    source.use { input ->
        sink.use { output ->
            output.writeAll(input)
        }
    }
}
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.