Yesterday, this piece of code caused me a headache. I fixed it by reading the file line by line. Any ideas ?
The while loop never seems to get executed even though the no of lines in the file is greater than 1.
val lines = Source.fromFile( new File("file.txt") ).getLines;
println( "total lines:"+lines.size );
var starti = 1;
while( starti < lines.size ){
val nexti = Math.min( starti + 10, lines.size );
println( "batch ("+starti+", "+nexti+") total:" + lines.size )
val linesSub = lines.slice(starti, nexti)
//do something with linesSub
starti = nexti
}