If I’ve understood it correctly, one should be able to convert a file (or input steam) to a sequence by following function:
fun <T : Any> sequence(nextFunction: () -> T?): Sequence<T> () (kotlin doc)
This will require to pass a function to read bytes from the stream or file , one byte at a time.
The question is, does it make sense to have an extension function (or maybe member function) in File and InputStream to private such Sequence instance ? (I mean in Kotlin standard library)