Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A File class object may refer to a data file or a directory. The Netbeans project DirectoryListDemo , using File class methods list() and listFIle()

A File class object may refer to a data file or a directory. The Netbeans project DirectoryListDemo, using File class methods list() and listFIle(). The Netbeans project CreateDirectoriesDemo, using the File class method mkdir(). The NetBeans project CopyFileDemoE has a method to copy a file.

Your task is to use techniques from all three of these examples to create software that can be used to copy a directory and all of its contents, including subdirectories and their contents.

Processing Data Files and Directories in Java

Your software should:

1. Ask the user for the source directory and a destination. The source is the directory to be copied; the destination is the directory that will be the parent of the new copy.

2. First your program should make a new directory in the new location with the same name as the source directory. (You may need to do something special for root directories if you are copying an entire disk. A root directory has no parent directory, and often, no name.)

3. Then your program should create an array with File class objects for each item in the contents of the source directory, similar to what was done in DirectoryListDemo.

4. Next , it should iterate the array, and for each item in the array,

a)if it is a file, copy the file to the new directory using the copyFile() method taken from CopyFileDemoE.

b)if it is a directory, recursively call this method to copy the directory and all of its contents.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

Is considering segments of one buyer a reality or a myth? Discuss.

Answered: 1 week ago

Question

Identify a set of competencies for tenured faculty

Answered: 1 week ago

Question

x-3+1, x23 Let f(x) = -*+3, * Answered: 1 week ago

Answered: 1 week ago