Here you can find the source of visitAllFiles(File dir, Visitor
public static void visitAllFiles(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 visitAllFiles(File dir, Visitor<File, IOException> visitor) throws IOException, FileNotFoundException { File[] list = dir.listFiles(); if (list != null) { for (File sub : list) { if (sub.isFile()) visitor.visit(sub);// w ww .ja va 2 s. c o m else visitAllFiles(sub, visitor); } } } }