I want to take integers from a file and put put them into an array but it keeps giving me a null pointer error. The text file is 100 lines with a single integer on each. When I debug it the file is being read and the proper integer is being stored but when I try to send it to my popBArray method it doesn't work.
public void readBoardFile(String filename) {
try {
Scanner filescanner = new Scanner(new File(filename));
while (filescanner.hasNextLine()) {
String line = filescanner.nextLine();
int num = Integer.parseInt(line);
popBarray(num);
}
filescanner.close();
} catch (IOException e) {
System.out.println(e);
} catch (Exception e) {
System.out.println(e);
}
}
int c = 0;
public void popBarray(int sent) {
BoardA[c] = sent;
c++;
}