please can you help me solve this question, i have written the codebut for some
ID: 3614908 • Letter: P
Question
please can you help me solve this question, i have written the codebut for some reason it says"java.io.file not found expection"
the questiion is
Write a program that asks the user for the names of two files. Thefirst file should be opened for reading and the second file shouldbe opened for writing. The program should read the contents of thefirst file, change all characters to uppercase, and store theresults in the second files. The second file will be a copy of thefirst file, except that all the characters will be uppercase. UseNotepad or another text editor to create a simple file that can beused to test the program.
what i wrote is
import java.util.Scanner; // Needed for theScanner class
importjava.io.*; // Needed for file classes
public class Uppercase2
{
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 =inputFile.readLine()) != null)
{
System.out.println(writing);
// writing =inputFile.readLine();
String upper = writing.toUpperCase();
System.out.println(upper);
outputFile.println(upper);
}
// close IO streams
outputFile.close();
inputFile.close();
}
}
Explanation / Answer
please rate - thanks your program works perfectly. this is a run ----jGRASP exec: java untitled Enter the first filename: input.txt Enter the second filename: output.txt this is THIS IS test of program TEST OF PROGRAM ----jGRASP: operation complete. Did you create the input file? sounds like you didn't your input file can't be found
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.