Not sure why this is getting a NullPointerException.
According to error log, NullPointerException is thrown while executing this statement. "file[i] = loadSaveFile.nextLine()" towards the end of the script.
public class SaveGame {
static String[] file;
static String loadSaveFile;
static String gameDir;
static int numLines = 0;
public static void main(String[] args) throws FileNotFoundException {
File saveFile = new File(gameDir + "\\savefile.txt");
Scanner loadSaveFile = new Scanner(saveFile);
Scanner findNumLines = new Scanner(saveFile);
while(findNumLines.hasNext() != false){
findNumLines.nextLine();
numLines++;
}
for (int i = 0; i < numLines; i++) {
file[i] = loadSaveFile.nextLine();
if(loadSaveFile.hasNextLine() == false){
break;
}
}
}
}