If you choose to use recursion, I found an example that may be close to the one you are currently using as to eliminate any ambiguity .
// Process only directories under dir
public static void visitAllDirs(File dir) {
if (dir.isDirectory()) {
process(dir);
String[] children = dir.list();
for (int i=0; i<children.length; i++) {
visitAllDirs(new File(dir, children[i]));
}
}
}
This is a very simple example, the process()
can be where you do your handling or operations on the directory.