Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started