public class ListFiles {
public static void main(String[] args) {
parseFiles(new File("C:/Users/82341/Desktop/Tools"),0);
}
public static void parseFiles(File f,int level) {
if (f == null || !f.exists()) {
return;
}
File[] files = f.listFiles();
for (File file : files) {
for (int i = 0; i < level; i++) {
System.out.print(" ");
}
System.out.println(file.getName());
if (file.isDirectory()) {
parseFiles(file,level++);
}
}
}
}