Question: Java Based Programming. The CopyFile Class Create an application class called CopyFile with the following fields and methods: Fields: private static Scanner input private static
Java Based Programming. The CopyFile Class Create an application class called CopyFile with the following fields and methods:
Fields:
private static Scanner input
private static Formatter output
Methods:
public static void openInFile(String fileName) - Gets a file-name and creates the input object according to the file-name.
public static void openOutFile(String fileName) - Gets a file-name and creates the output object according to the file-name.
public static void copyRecords() - Reads records from the input file and writes them into the output file. (After writing each record into the output file, shows that record on the screen) - Shows a successful message after copying all records.
public static void closeInFile() - Closes the input object
public static void closeOutFile() - Closes the output object
public static void main(String[] args) - Calls openInFile method to open "Student.txt" file as the source file. - Calls openOutFile method to open "StudentCopy.txt" file as the destination file. - Calls copyRecords method to copy records from "Student.txt" file into "StudentCopy.txt" file. - Calls closeInFile method to close the input file (source file). - Calls closeOutFile method to close the output file (destination file).
Note: Student.txt file is attached as the source file for copying
Student.txt
1111 Sophia Miller Finance 3.24 1122 Mason Brown Marketing 3.05 1133 William Johnson Economics 3.71 1144 Emma Wilson Accounting 4.00 1155 Abigail Jones Marketing 3.52 1166 Emily Davis Management 2.98 1177 James Anderson Finance 3.36 1188 Madison Taylor Management 3.82 1199 Robert Smith Accounting 2.91 1211 David Williams Economics 3.60
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
