Question about loadstrings() function

It is tossing the line terminators, but it is still indexing the lines in the array – it doesn’t “skip” them or “toss” them completely.

Given a five line text file, foo.txt:

foo

bar

baz

This code:

String[] strs = loadStrings("foo.txt");
for(int i=0; i<strs.length; i++){
  println(i, strs[i]);
}

outputs:

0 foo
1
2 bar
3
4 baz

2 Likes