« Return to Thread: Source.fromFile(file).getLines

Source.fromFile(file).getLines

by Gilles SCOUVART :: Rate this Message:

Reply to Author | View in Thread

Hello all,
 
I was surprised to notice that using Source.fromFile(file).getLines on a file with empty lines, those were added to the previous non empty line.
I.e. if the file contains this:
------
test
 
 
------
then getLines.next would return "test\n\n" (written java-echap-style).
I expected it would iterate on three lines instead: "test", "", and "".
This is a little bit annoying for pattern matching on full lines...
 
Is this expected behaviour?
 
Gilles Scouvart.

 « Return to Thread: Source.fromFile(file).getLines