private void listFilesRecursively(File file) {
if (file.isDirectory()) {
System.err.printf("Directory %s:%n", file.getAbsoluteFile());
for (File child : file.listFiles()) {
listFilesRecursively(child);
}
} else {
System.err.printf("File %s%n", file.getAbsoluteFile());
}
}
public static void main(String[] args) {
listFilesRecursively(new File("."));
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter