Java Files  «Prev  Next»


Working with directories and paths - Exercise

Working with Directories and Paths

This exercise consists of two parts.
First, write a program that recursively lists all the files in a directory, all the files in any directories in that directory, all the files in the directories in the directories in the directory, and so on. Paste the source code below.


Many operating systems provide some version of aliases, symbolic links, or shortcuts that allow a directory to contain one of its parents. Given this possibility, how can you avoid getting stuck in an infinite loop when recursively enumerating directories as in the exercise?
Type your answer to this question in the text box below and click the Submit button to submit your response.