Why am I getting a NullPointerException
I am my program working properly but I am trying to use an input() method in a different class to perform the readLine() operation from the data file. I am passing a BufferedReader object to the input() method. I now can not get rid of the NullPointerException. I commented out the original while loop that was the while loop of the original working program. What is causing my NullPointerException problem?
Thanks.
private static BufferedReader checkSorted(BufferedReader filePath) throws IOException, FileUnsorted {
String numbers = null;
Polynomial polyObjA = null;
Polynomial polyObjB = null;
Polynomial p = null;
numbers = p.input(filePath);
//while ((numbers = filePath.readLine()) != null) {
while(numbers != null) {
polyObjB = new Polynomial(numbers);
sortedList.add(polyObjB);
if (polyObjA != null) {
if (polyObjA.compareTo(polyObjB) > 0) {
throw new FileUnsorted("Error: File is not sorted");
}
}
polyObjA = polyObjB;
}
return new BufferedReader(filePath);
}
public String input(BufferedReader filePath) throws IOException{
String number = "";
System.out.println("I'm in input");
number = filePath.readLine();
return number;
}