<Kotlin - read only first n lines in file> Is ther...
# stackoverflow
u
Kotlin - read only first n lines in file Is there a method, without resolving to traditional Java-like for loops, to limit the number of lines read by BufferedReader? Take this code for example: bufferedReader.useLines { it } .take(10) .toList() The documentation for useLines states: Calls the [block] callback giving it a sequence of all the lines in this file and closes the reader once * the processing is complete. To my understanding, this means that the entire file will be read, and only then...