I don’t know if there’s a Kotlin version of it or not, but I’ve done this in Kotlin using Java’s PipedInputStream and PipedOutputStream like so:
val writer = PipedOutputStream()
val reader = PipedInputStream(writer)
// Write to the stream
writer.write(...)
// Read from the stream
reader.read() // Or reader.readLine(), etc. This will block until there is something to be read