Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I got a help and fixed, but I got an error said Exception in thread \"main\" jav

ID: 3613800 • Letter: I

Question

I got a help and fixed, but I got an error said

Exception in thread "main" java.lang.NullPointerException
at Uppercase.main(Uppercase.java:60)

What does it mean?
Thank you!!

import java.util.Scanner;    // Needed for theScanner class
import java.io.*;           // Needed for file classes

public class Uppercase
{
    public static void main(String[] args) throwsIOException
    {
        String filename;
        String filename2;
        String writing;

        // Create a Scannerobject for keyboard input.
        Scanner keyboard = newScanner(System.in);

        // Get the firstfilename.
        System.out.print("Enterthe first filename: ");
        filename =keyboard.nextLine();

        // get the secondfilname
        System.out.print("Enterthe second filename: ");
        filename2 =keyboard.nextLine();

        // Open the readingfile.
        FileReader freader = newFileReader(filename);
        BufferedReader inputFile= new BufferedReader(freader);
   
        // open output file
        FileWriter fwriter = newFileWriter(filename2);
        PrintWriter outputFile =new PrintWriter(fwriter);

       writing =inputFile.readLine();
      
        while (writing !=null)
        {
           System.out.println(writing);
           writing = inputFile.readLine();
          
           //write
           Stringupper = writing.toUpperCase();
           System.out.println(upper);
           outputFile.println(upper);
        }
          
        // close IO streams
        outputFile.close();
        inputFile.close();
    }
}

Explanation / Answer

Fixed as per your PM. import java.util.Scanner;// Needed for the Scanner class import java.io.*; // Needed for fileclasses public class Uppercase { publicstatic void main(String[]args) throws IOException { String filename; String filename2; String writing; //Create a Scanner object for keyboard input. Scanner keyboard =new Scanner(System.in); //Get the filename. System.out.print("Enter thefirst filename: "); filename = keyboard.nextLine(); //get the second filname System.out.print("Enter thesecond filename: "); filename2 = keyboard.nextLine(); //Open the file. FileReader freader =new FileReader(filename); BufferedReader inputFile= newBufferedReader(freader); //open output file FileWriter fwriter= newFileWriter(filename2); PrintWriter outputFile = new PrintWriter(fwriter); //Read while ((writing =inputFile.readLine()) != null) { System.out.println(writing); writing = inputFile.readLine(); // write System.out.println(writing.toUpperCase()); outputFile.println(writing); } //close IO streams outputFile.close(); inputFile.close(); } }