Here you can find the source of visitAllSubDirectories(File dir, Visitor
public static void visitAllSubDirectories(File dir, Visitor<File, IOException> visitor) throws IOException, FileNotFoundException
import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; public class Main{ public static void visitAllSubDirectories(File dir, Visitor<File, IOException> visitor) throws IOException, FileNotFoundException { File[] list = dir.listFiles(); if (list != null) { for (File sub : list) { if (sub.isDirectory()) { visitor.visit(sub);/*from www . jav a 2s . c om*/ visitAllSubDirectories(sub, visitor); } } } } }