Code
try (BufferedReader br = new BufferedReader(new FileReader(path))) {
while((line = br.readLine()) != null){ //Reads a line, assigns it to line.
String input = br.readLine(); //Reads the next line, assigns it to input.
You read the line into the "line" variable - don't do anything with it, then read the next line into the "input" variable and do something with it. Effectively, reading every other line.
The exception is because since you read a line in the condition for the while loop, there will be a line there, but then you read it again into input and there will not be an additional line - causing the null exception.
Attempt this modification:
Code
try (BufferedReader br = new BufferedReader(new FileReader(path))) {
while((line = br.readLine()) != null){
String[] data = line.split(" ");
This post was edited by Kippet on Sep 25 2020 10:36pm