Okay, so I have a method that writes the content of an integer array to a file, one per line. This is part of a bigger class, but I can confirm that everything works except for this last method.
The exception that Java throws is a NullPointerException, so.. y'know. Null pointer.
Here's the relevant code:
Code:
import java.io.FileWriter;
import java.io.IOException;
...
private static void printArray(int[] arr, String outFile){
try {
FileWriter outputFile = new FileWriter(outFile);
for(int i = 0; i < arr.length; i++){
String intWriter = Integer.toString(arr[i]);
outputFile.write(intWriter + "\n");
}
outputFile.close();
System.out.println("Successsfully written " + outFile + "\n");
}
catch(IOException ex){
ex.printStackTrace();
}
}
I honestly don't know what's wrong here and it's pissing me off.
EDIT: The exact line that gives the exception is underlined now.
Bookmarks