Manuel Pérez Alcolea
03/26/2023, 7:15 PMByteReadChannel
, ByteWriteChannel
, what's the benefit of them? And what does the following mean?
Operations on this channel cannot be invoked concurrently.when is a
ByteWriteChannel
more convenient than this?
val url = URL(...)
val targetDir = Path.of(...)
withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
url.openStream().use { stream ->
Files.copy(stream, targetDir)
}
}
are they just meant to be used to read and write in chunks without blocking everything else in a thread, and to yield it to other coroutines?Aleksei Tirman [JB]
03/27/2023, 9:39 AM