Question: Write a method void listAllFiles(File dir) that recursively displays a list of a directory's files and subdirectories. An example is illustrated below. Note the following
Write a method void listAllFiles(File dir) that recursively displays a list of a directory's files and subdirectories. An example is illustrated 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.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
