Assignment 3 In this assignment you will practice file input and output. You are given two options: those who think up t
Posted: Fri Apr 29, 2022 7:15 am
Write code in JAVA Language. and do part 1 and 2. Send answer as
soon as possible. and also write comment for each part of the
code!
Assignment 3 In this assignment you will practice file input and output. You are given two options: those who think up to 60% is enough for them, solve the first part. Those who think they are to get full point, continue with the second part Part1 (basic: 60%) We have already seen how to copy a file using java. Utilizing that knowledge write a program that given a list of files (names) and the destination (all through command line input as executing the program), it will copy all those files into the destination folder. Note: if a specified path is a directory, mention that it is a directory, and skip copying it. Note: handle all the possible exceptional cases and user error. Note: every time a file is copied, print the number of bytes copied. Example: if file size is 36 bytes, print 36 B. if file size is 3635 bytes, print 4 KB. if file size is 3635124 bytes, print 4 MB. Part2 (medium: 40%) Given a list of directories and files followed by the destination copy all these directories(recursively) and files into the destination. Note: all the subdirectories and files inside the given directories must be kept in the same nested structure in destination folder.
Assume that the folder structure is as following: (use tree IF command to see the directory structure recursively, just tree on Mac or Linux) dest resources docs -books some citations.txt american London BEFORE ADAM.txt THE IRON HEEL.txt The People of the Abyss.txt -russian -Dostoevsky The Gambler.txt THE POSSESSED (The Devils).txt -Tolstoy MASTER AND M.Et -personal doc.txt doc2.txt Sened.docx adal.12 పదవ7.jpg download (1).jpg download.jpg Part1: Executing Java YourAppName "resources/img/ada 1.jpg" "resources/docs/books/some citations.txt" Output >Started: resourceslimglada1.jpg... >Finished FILE: resourceslimglada 1.jpg >Total 11KB were copied! >Started: resources docs\books some citations.txt... >Finished FILE: resources docs books some citations.txt >Total 435B were copied! -dest ada1.jpg some citations.txt Produces a dest) folder structure: Note: as you see, only the specified file(s) (not their paths) are created in the destination folder. a
Part2 Executing java YourAppName "resources/docs/books" "resources/docs/books/some citations.txt" dest Output: [Note that every nested folder and its contents are printed with one more indentation] >Started: resources docsbooks... >Started: resources docs books american... >Started: resources docs books american London... >Started: resources docs bookslamerican London BEFORE ADAM.txt... >Finished FILE: resources docs books american London BEFORE ADAM.txt >Total 229KB were copied! >Started: resources docs books american London THE IRON HEEL.txt... >Finished FILE: resources docs books american London THE IRON HEEL.txt >Total 528KB were copied! >Started: resources docs books american London The People of the Abyss.txt... >Finished FILE: resources docs books american London The People of the Abyss.txt >Total 370KB were copied! >Finished FOLDER: resources docs\books american London >Finished FOLDER: resources docs books american >Started: resources\docs\books russian... >Started: resources docs\booksvussian Dostoevsky... >Started: resources docs books russian Dostoevsky The Gambler.txt... >Finished FILE: resources docs\books russian Dostoevsky The Gambler.txt >Total 357KB were copied! >Started resources docs books russian Dostoevsky THE POSSESSED (The Devils). Ext... >Finished FILE: resources docs books russian Dostoevsky THE POSSESSED (The Devils).txt >Total 2MB were copied! >Finished FOLDER: resources docs\books russian Dostoevsky >Started: resources docs\books russian Tolstoy... >Started: resources docs books russian Tolstoy\MASTER AND MAN.txt... >Finished FILE: resources docs books russian Tolstoy\MASTER AND MAN.EXE >Total 127KB were copied! >Finished FOLDER: resources docs books russian Tolstoy >Finished FOLDER: resourcesdocs\books russian >Started: resources docs\books some citations.txt... >Finished FILE: resources docs books some citations.txt >Total 435B were copied! >Finished FOLDER: resources\docsbooks >Started: resources docs books some citations.txt... >Finished FILE: resources docs\books some citations.txt >Total 435B were copied!
-dest sone citations.txt -books some citations.txt -american London BEFORE ADAM.txt THE IRON HEEL.txt The People of the Abyss.txt russian Dostoevsky The Gambler.txt THE POSSESSED (The Devils).txt Tolstoy MASTER AND MAN.txt Produces a (dest) folder structure:
soon as possible. and also write comment for each part of the
code!
Assignment 3 In this assignment you will practice file input and output. You are given two options: those who think up to 60% is enough for them, solve the first part. Those who think they are to get full point, continue with the second part Part1 (basic: 60%) We have already seen how to copy a file using java. Utilizing that knowledge write a program that given a list of files (names) and the destination (all through command line input as executing the program), it will copy all those files into the destination folder. Note: if a specified path is a directory, mention that it is a directory, and skip copying it. Note: handle all the possible exceptional cases and user error. Note: every time a file is copied, print the number of bytes copied. Example: if file size is 36 bytes, print 36 B. if file size is 3635 bytes, print 4 KB. if file size is 3635124 bytes, print 4 MB. Part2 (medium: 40%) Given a list of directories and files followed by the destination copy all these directories(recursively) and files into the destination. Note: all the subdirectories and files inside the given directories must be kept in the same nested structure in destination folder.
Assume that the folder structure is as following: (use tree IF command to see the directory structure recursively, just tree on Mac or Linux) dest resources docs -books some citations.txt american London BEFORE ADAM.txt THE IRON HEEL.txt The People of the Abyss.txt -russian -Dostoevsky The Gambler.txt THE POSSESSED (The Devils).txt -Tolstoy MASTER AND M.Et -personal doc.txt doc2.txt Sened.docx adal.12 పదవ7.jpg download (1).jpg download.jpg Part1: Executing Java YourAppName "resources/img/ada 1.jpg" "resources/docs/books/some citations.txt" Output >Started: resourceslimglada1.jpg... >Finished FILE: resourceslimglada 1.jpg >Total 11KB were copied! >Started: resources docs\books some citations.txt... >Finished FILE: resources docs books some citations.txt >Total 435B were copied! -dest ada1.jpg some citations.txt Produces a dest) folder structure: Note: as you see, only the specified file(s) (not their paths) are created in the destination folder. a
Part2 Executing java YourAppName "resources/docs/books" "resources/docs/books/some citations.txt" dest Output: [Note that every nested folder and its contents are printed with one more indentation] >Started: resources docsbooks... >Started: resources docs books american... >Started: resources docs books american London... >Started: resources docs bookslamerican London BEFORE ADAM.txt... >Finished FILE: resources docs books american London BEFORE ADAM.txt >Total 229KB were copied! >Started: resources docs books american London THE IRON HEEL.txt... >Finished FILE: resources docs books american London THE IRON HEEL.txt >Total 528KB were copied! >Started: resources docs books american London The People of the Abyss.txt... >Finished FILE: resources docs books american London The People of the Abyss.txt >Total 370KB were copied! >Finished FOLDER: resources docs\books american London >Finished FOLDER: resources docs books american >Started: resources\docs\books russian... >Started: resources docs\booksvussian Dostoevsky... >Started: resources docs books russian Dostoevsky The Gambler.txt... >Finished FILE: resources docs\books russian Dostoevsky The Gambler.txt >Total 357KB were copied! >Started resources docs books russian Dostoevsky THE POSSESSED (The Devils). Ext... >Finished FILE: resources docs books russian Dostoevsky THE POSSESSED (The Devils).txt >Total 2MB were copied! >Finished FOLDER: resources docs\books russian Dostoevsky >Started: resources docs\books russian Tolstoy... >Started: resources docs books russian Tolstoy\MASTER AND MAN.txt... >Finished FILE: resources docs books russian Tolstoy\MASTER AND MAN.EXE >Total 127KB were copied! >Finished FOLDER: resources docs books russian Tolstoy >Finished FOLDER: resourcesdocs\books russian >Started: resources docs\books some citations.txt... >Finished FILE: resources docs books some citations.txt >Total 435B were copied! >Finished FOLDER: resources\docsbooks >Started: resources docs books some citations.txt... >Finished FILE: resources docs\books some citations.txt >Total 435B were copied!
-dest sone citations.txt -books some citations.txt -american London BEFORE ADAM.txt THE IRON HEEL.txt The People of the Abyss.txt russian Dostoevsky The Gambler.txt THE POSSESSED (The Devils).txt Tolstoy MASTER AND MAN.txt Produces a (dest) folder structure: