Question: Having trouble with the void listAllFiles (File dir, String spaces) method [20 marks] Write a method void listAllFiles (File dir) that recursively displays a list

Having trouble with the void listAllFiles(File dir, String spaces) method

Having trouble with the void listAllFiles(File dir, String spaces) method [20 marks]

[20 marks] Write a method void listAllFiles (File dir) that recursively displays a list of a directory's files and subdirectories. An example is illustratep below. Note the following in the output: . Directory names are all capitalized and written between brackets []. Files and subdirectories are indented in order to illustrate to which parent directory they belong. Use a helper method void listAllFiles (File dir, String spaces) where dir represents the root directory (i.e., Folder 1 in the example below) and spaces stores a number of spaces" " that is incremented every time the method is recursively called. The helper method should print out spaces followed by the file or subdirectory names. Folder structure on the hard drive Computer ' Local Disk (C) OUTPUT from your Java Program for "Folder 1" [FOLDER 1] Folder 1 4Folder X file 1.pdf file 2.pdf [FOLDER X] Folder A Folder B file 1.pdf file 2.pdf file 3.pdf [FOLDER A] Folder Y file 1.pdf file 2.pdf FOLDER B] file 1.pdf file 2.pdf [FOLDER Y] file 1.pdf file 2.pdf [20 marks] Write a method void listAllFiles (File dir) that recursively displays a list of a directory's files and subdirectories. An example is illustratep below. Note the following in the output: . Directory names are all capitalized and written between brackets []. Files and subdirectories are indented in order to illustrate to which parent directory they belong. Use a helper method void listAllFiles (File dir, String spaces) where dir represents the root directory (i.e., Folder 1 in the example below) and spaces stores a number of spaces" " that is incremented every time the method is recursively called. The helper method should print out spaces followed by the file or subdirectory names. Folder structure on the hard drive Computer ' Local Disk (C) OUTPUT from your Java Program for "Folder 1" [FOLDER 1] Folder 1 4Folder X file 1.pdf file 2.pdf [FOLDER X] Folder A Folder B file 1.pdf file 2.pdf file 3.pdf [FOLDER A] Folder Y file 1.pdf file 2.pdf FOLDER B] file 1.pdf file 2.pdf [FOLDER Y] file 1.pdf file 2.pdf

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!