https://kotlinlang.org logo
p

poohbar

10/22/2017, 1:25 AM
I would like to turn a file into a (lazy) sequence of lines, so I did this:
File(path).bufferedReader().lineSequence()
Now,
lineSequence()
warns that I have to take care of closing the input stream but how would I go about doing that? E.g. how do I know the sequence has been exhausted and it's time to close the flie? I can't use
useLines()
in this case, because I am returning this sequence out of a function.
2 Views