Here you can find the source of recursiveListFiles(File dir, FileFilter filter)
public static File[] recursiveListFiles(File dir, FileFilter filter)
//package com.java2s; //License from project: Apache License import java.io.*; import java.util.ArrayList; import java.util.List; public class Main { public static File[] recursiveListFiles(File dir, FileFilter filter) { if (!dir.isDirectory()) throw new IllegalArgumentException(dir + " is not a directory"); List<File> fileList = new ArrayList<File>(); recursiveListFilesHelper(dir, filter, fileList); return fileList.toArray(new File[fileList.size()]); }//from w w w . j a va 2 s.c om public static void recursiveListFilesHelper(File dir, FileFilter filter, List<File> fileList) { for (File f : dir.listFiles()) { if (f.isDirectory()) { recursiveListFilesHelper(f, filter, fileList); } else { if (filter.accept(f)) fileList.add(f); } } } }