Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ood evening guys! I need to rewrite this program so that it asks the user for the location where the new directories are to be

ood evening guys! I need to rewrite this program so that it asks the user for the location where the new directories are to be created, and then asks the user to enter, one at a time, the relative path names of the directories it should create.

package createdirectoriesdemo; import java.io.*; import java.util.Scanner;

public class CreateDirectoriesDemo {

public static void main(String[] args) {

// Establish the location of the parent for the new set of directories. // This could be changed to user input. String location = "c:/"; // create a String array of the directories to be created String[] folderPaths = { "/Spring Semester", "/Spring Semester/ENGL 101", "/Spring Semester/CSCI 111", "/Spring Semester/MATH 163", "/Spring Semester//PHYS 111", "/Spring Semester/CSCI 111/programs", "/Spring Semester/CSCI 111/docs" }; // create a File class array for directories to be created File[] newFolders = new File[folderPaths.length]; // create new directories based on the file names in the array for (int i = 0 ; i < newFolders.length; i++) { // create a File object for this new directory // based on the parent location and each new path name newFolders[i] = new File( location + folderPaths[i] ) ; // make the new directory newFolders[i].mkdir(); } // end for } // end main() } // end class CreateDirectoriesDemo

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

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

2. Develop a persuasive topic and thesis

Answered: 1 week ago

Question

1. Define the goals of persuasive speaking

Answered: 1 week ago