tony
May 14, 2020, 1:02am
2
Good question. I believe this might be expected behavior. After some digging, it looks like loadStrings() utilizes a BufferedReader:
}
return null;
}
static public String[] loadStrings(BufferedReader reader) {
try {
String lines[] = new String[100];
int lineCount = 0;
String line = null;
while ((line = reader.readLine()) != null) {
if (lineCount == lines.length) {
String temp[] = new String[lineCount << 1];
System.arraycopy(lines, 0, temp, 0, lineCount);
lines = temp;
}
lines[lineCount++] = line;
}
reader.close();
if (lineCount == lines.length) {
Inside, we can see readline() being called, and according to the docs :
Returns:
A String containing the contents of the line, not including any line-termination characters , or null if the end of the stream has been reached
In short, it’s tossing the empty lines.
1 Like