Kotlin Suspending versions of InputStream and OutputStream

Viewed 137

Astoundingly, Kotlin doesn't seem to provide suspending versions of InputStream and OutputStream.

It's not hard to roll your own, but that doesn't give you the kind of default compatibility with other code that these ubiquitous interfaces provide in Java.

What would I use for suspending stream interfaces in Kotlin if I wanted to maximize interoperability without adapters?

1 Answers

I think that the primary way for doing IO with purely Java APIs is just calling blocking methods in the context of Dispatchers.IO.

However, there is ktor-io library by JetBrains that implements IO in a purely suspending way.

Related