Aide mémoire : Exploration de dossier
Petit aide mémoire pour explorer le contenu d’un dossier de manière récursive. 1. Java 6 2. Java 7 3. Sources 1. Java 6 public void run() { File f = new File(fileOrFolderPath); if (f.isDirectory()) { parseFolder(f); } else { parseFile(f); } } /** * Recursively parse given folder. */ protected void parseFolder(File directory) { doAtStartOfEachFolder(directory); for (File file : directory.listFiles()) { if (file.isDirectory()) { parseFolder(file); } else { parseFile(file); } } doAtEndOfEachFolder(directory); } /** * […]