Question: 1 . Begin by examining the FileOperation class that has been provided to you in the homework package. The class represents the result of a
Begin by examining the FileOperation class that has been provided to you in the homework package. The class represents the result of a file operation, eg attempting to copy or delete a file.
a The Result enumeration indicates whether the operation was a SUCCESS or an ERROR.
b The message provides a detailed description of the result.
Next, examine the FileUtils class that has been provided to you in the homework package.
a The copyFileString source, String destination method will copy a file from the source path to the destination path. The FileOperation that is returned indicates whether the operation succeeded or failed and why You may test the method by running the class and using command line arguments to specify the source and destination file paths.
b The clearDirectoryString path method will delete all of the files in the specified directory. The FileOperation that is returned indicates whether the operation succeeded or failed and why Be extremely careful when testing this method as you do not want to unintentionally delete any directories! If you accidentally delete files from your project, use the git status and git restore commands to restore them.
Create a class named FileCopier. Add a main method.
a Two directories should be specified as commandline arguments. If there are not exactly two commandline arguments, print a usage message, eg "Usage: java homework.FileCopier and exit with an error code.
b Use the FileUtils class to make sure that the output directory is cleared.
c Use the FileUtils class to copy the files from the input directory to the output directory. Print a message just before each file is copied.
d Read the documentation on the java.ioFile class including the listFiles method. Use it to list the files in the input directory and copy them into the output directory one at a time. If the file is a directory, skip it Print a message indicating that it was skipped.
e Print a message at the end indicating how many files were copied, the total bytes copied, and the time that it took to copy them.
f If any errors occur, print a detailed message and exit with an error code. Do not rethrow the exception.
g Below is example output:
Clearing directory 'output'.
Copying file 'books.png
Copying file 'buttercup.jpg
Copying file 'cutie.jpg
Skipping directory 'skipme
Copying file 'tacos.jpg
Copying file 'words.txt
Copied files bytes in milliseconds.
Create a new class, CopierThread that copies a single file in a separate thread of execution.
a The class will need the name of the file to copy as well as the name of the destination directory into which the file should be copied.
b You will need to implement the copy in the threads run method. If an exception occurs, save the result in a field and abort the copy.
c The name of the file should be printed just before it is copied.
d It should provide accessors for the number of bytes copied, and the result of the copy.
e Add a main method that creates one CopierThread per file in the input directory and produces the same output as the main method in FileCopier including if one or more of the threads encounters an error This main method should keep track of the total time.
f Below is example output:
Clearing directory 'output'.
Copying file 'books.png
Skipping directory 'skipme
Copying file 'buttercup.jpg
Copying file 'cutie.jpg
Copying file 'tacos.jpg
Copying file 'words.txt
Copied files bytes in milliseconds.
bonus Create a new class, Counter, that prints a single number in a separate thread.
a Add a main method that accepts a single commandline argument that specifies the number to count up to If there is not exactly one commandline argument, print a usage message, eg "Usage: java homework.Counter and exit with an error code.
b Create and start one of your Counter threads for each number. For example, if the number is you should create threads with the numbers through inclusive
c You must ensure that the numbers print in order. In order to do this, each thread should wait until the previous thread has finished before printing its own number.
d Test your implementation several times with at least threads. Ensure that the numbers print in the exact correct order each and every time.
e Below is example output:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
