This is my code example and all seems to be working with inputting data, however when trying to export the input data to an output the code is returning the error:
"Exception in thread "main" java.lang.NullPointerException at JavaProject.main(JavaProject.java:50)"
I have included a gyazo snapshot of how it looks and the error:
import java.util.Scanner;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
public class JavaProject {
private static char[] input;
@SuppressWarnings("null")
public static void main(String[] args) {
int hrs, mins;
int[] gameCount;
int[] MinutesPlayed = null;
String GamerName, GamerReport;
//Main data storage arrays
String[] GameNames = new String[100];
int[] HighScores = new int[100];
Scanner Scan = new Scanner(System.in);
//formatting for output and input
System.out.println("////// Game Score Report Generator \\\\\\\\\\\\");
System.out.println(" ");
//user enters name and then moves to next line
System.out.println("Enter Your Name");
GamerName = Scan.nextLine();
//user is given an example of input format
System.out.println("Input Gamer Information " + "Using Format --> Game : Achievement Score : Minutes Played");
System.out.println(" ");
System.out.println("Game : Achievement Score : Minutes Played");
GamerReport = Scan.nextLine();
String[] splitUpReport; // an array of string
splitUpReport = GamerReport.split(":"); // split the text up on the colon
int i = 1;
//copy data from split text into main data storage arrays
GameNames[i] = splitUpReport[0];
HighScores[i] = Integer.parseInt(splitUpReport[1].trim() );
MinutesPlayed[i] = Integer.parseInt(splitUpReport[2].trim());
//output to file
try
{
FileWriter writer = new FileWriter("output.txt");
writer.write(GamerReport);
writer.close();
} catch (IOException e)
{
System.err.println("File does not exist!");
}