Here is my code to take a look, I have been fighting with it for an hour now and I think this is the class killing my progress, does the 30 in the error shown at the bottom represent the error being in line 30 but since that is the while loop does that mean the whole loop is flawed? I am wracking my head to figure this out with no luck.
import java.util.Scanner;
import java.io.File;
import java.util.regex.Pattern;
public class ContributorManager {
public static void main(String [] args) {
Scanner inputFile = null;
String name = null;
String city = null;
String country = null;
String phone = null;
double contribution = 0;
int id = 0;
Contributor c = null;
TheStack stack = new TheStack();
Node1 node = null;
//open contributors file
try {
inputFile = new Scanner(new File("contributors.csv"));
inputFile.useDelimiter(Pattern.compile("(\\n)|(\\r)|,"));
}
catch (Exception e) {
System.err.println("Error opening file.");
}
//create contributors object for each row, and add to the stack
while (inputFile.hasNext()) {
name = inputFile.next();
city = inputFile.next();
country = inputFile.next();
phone = inputFile.next();
contribution = inputFile.nextDouble();
id = inputFile.nextInt();
inputFile.nextLine(); //advance to the next line
c = new Contributor(name, city, country, phone, contribution, id);
node = new Node1(c); //create a node using the contributor object
stack.push(node); //add the node to the top of the stack
}
stack.pop(); //remove the last node from the top of the stack
stack.print(); //print the contents of the entire stack
}
}
And here is the error exactly as I see it, I am new so I do not have the best ability to find my own errors as often as they happen, thank you.
Error opening file.
Exception in thread "main" java.lang.NullPointerException
at ip1_second_try/Module.ContributorManager.main(ContributorManager.java:30)