A data read loop threw a nullPointerException in some cases.
The input list contained numbers and strings mixedly, but I read them all as strings one after the other, into a string ArrayList:
while (true) {
String s = reader.readLine();
if (s.isEmpty()) break;
list.add(s);
}
The nullPointerException is understandable:
I checked the "s" elements with a System.out.println(s) command, and the last of all "s" contained a "null" after the last item of the inputlist. But why?...
Therefore, the cycle had to be corrected to:
while (true) {
String s = reader.readLine();
if (s==null || s.isEmpty()) break;
list.add(s);
}
This way it worked already nicely:) (without any Exception.)
But the questions are:
1) Why does the program read such a "null" in some cases after the end of the inputlist?
2) Is this second cycle correct or should it still be refined?