Menu

[Solved] Lab Uses Series Classes Facilitate File Io Exercise 1 Copy File 5 Points Overview Purpose Q37172123

This lab uses a series of classes that facilitate file IO Exercise 1 - Copy a file (5 points) Overview The purpose of this exGet the input file (test.txt) from todays downloads Write the code to read from the file whose name is the input filename (th

Please help me!

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 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 Page 1 of 2 ISTE-120 Lab 12 up a loop and then to stop reading when it reaches the end of file. Make sure of handling all specific exceptions Sample Output Ex1 – bash 78×20 Janeway: Ex1 jim$ ls Copy.class Janeway:Ex1 jim$ cat test.txt Test Data for ISTE-120 Lab 13 12345678901234567890123456789012345678901234567890 abcdefghijklmnopqrstuvwxyzabcdefghijklmnopgrstuvwxyz Janeway: Ex1 jim$ java Copy test.txt testCopied.txt r aneway: Ex1 jim$ cat testCopied.txt Test Data for ISTE-120 Lab 13 12345678901234567890123456789012345678901234567890 abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz aneway: Ex1 jim$ java Copy test.txt testCopied.txt a Janeway: Ex1 jim$ cat testCopied.txt Test Data for ISTE-120 Lab 13 12345678901234567890123456789012345678901234567890 abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz Test Data for ISTE-120 Lab 13 12345678901234567890123456789012345678901234567890 abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz Janeway: Ex1 jim$ Copy.docx Copy.java test.txt Show transcribed image text 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
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 Page 1 of 2 ISTE-120 Lab 12 up a loop and then to stop reading when it reaches the end of file. Make sure of handling all specific exceptions Sample Output Ex1 – bash 78×20 Janeway: Ex1 jim$ ls Copy.class Janeway:Ex1 jim$ cat test.txt Test Data for ISTE-120 Lab 13 12345678901234567890123456789012345678901234567890 abcdefghijklmnopqrstuvwxyzabcdefghijklmnopgrstuvwxyz Janeway: Ex1 jim$ java Copy test.txt testCopied.txt r aneway: Ex1 jim$ cat testCopied.txt Test Data for ISTE-120 Lab 13 12345678901234567890123456789012345678901234567890 abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz aneway: Ex1 jim$ java Copy test.txt testCopied.txt a Janeway: Ex1 jim$ cat testCopied.txt Test Data for ISTE-120 Lab 13 12345678901234567890123456789012345678901234567890 abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz Test Data for ISTE-120 Lab 13 12345678901234567890123456789012345678901234567890 abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz Janeway: Ex1 jim$ Copy.docx Copy.java test.txt

Expert Answer


Answer to This lab uses a series of classes that facilitate file IO Exercise 1 – Copy a file (5 points) Overview The purpose of th… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *