Question: Please answer these problems, thank you! This lab uses a series of classes that facilitate file IO Exercise 1 Copy a file (5 points) Overview


Please answer these problems, thank you!
This lab uses a series of classes that facilitate file IO Exercise 1 Copy a file (5 points) Overview The purpose of this exercise is to use various IO classes. To keep things "simple" this exercise will only create one file and use only a "main" method Create a class called Copy that reads a file, copying its contents to another file. Get both filenames from the command line. Download a test file: test.txt from MyCourses to use as the source file. Requirements: Use the character IO classes FileReader and FileWriter (not Scanner and PrintWriter) Make certain there are three command line input parameters . o Input_filename o Output_filename, and if the output file already exists o r to replace it (overwrite it) or a to append to it Handle the FileNotFoundException, as well as an IOException Make sure to close both files when done making the copy. If the input file does not exist, display a message, "Input File not found" to the screen and stop the program . Check if the output file already exists using the appropriate method in the File class. If the output file exists and the 3rd command line parameter is 'r', then replace the existing file. If 'a', then append the new contents to the end of the existing file. Choose the proper constructor method of the FileWriter. If the output file does not exist, ignore the 3rd command line parameter. Get the input file (test.txt) from todays downloads Write the code to read from the file whose name is the input filename (the 1st command line argument- test.txt). As you read from the input file, write the characters read to the file whose name is the output filename (the 2nd command line argument- use testCopied.txt for this exercise). Think carefully about the condition required to set
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
