Here you can find the source of recursiveListFiles(File baseDir, final FileFilter filter)
public static List<File> recursiveListFiles(File baseDir, final FileFilter filter)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileFilter; import java.util.ArrayList; import java.util.List; public class Main { public static List<File> recursiveListFiles(File baseDir, final FileFilter filter) { FileFilter dirFilter = new FileFilter() { public boolean accept(File pathname) { return pathname.isDirectory() || filter.accept(pathname); }//from w w w . j ava 2s .c om }; File[] fileArray = baseDir.listFiles(dirFilter); List<File> files = new ArrayList<File>(fileArray.length); for (int i = 0; i < fileArray.length; i++) { if (fileArray[i].isDirectory()) { files.addAll(recursiveListFiles(fileArray[i], filter)); } else { files.add(fileArray[i]); } } return files; } }