I'm trying to mount a file tree where in addition to displaying the directories of the computer is also displayed its files. The code I've done below is only listing the specified directory, in this case C:\
. But the directories contained within C:
such as "Program Files" does not display what's inside.
package arvore;
import java.io.File;
public class Arvore {
public static void main(String[] args) {
File folder = new File("C:\");
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
System.out.println("Este é Arquivo " + listOfFiles[i].getName());
} else if (listOfFiles[i].isDirectory()) {
System.out.println("***ESTE E DIRETÓRIO " + listOfFiles[i].getName());
}
}
}
}
The question is how it would look to display all including subdirectories.