Here you can find the source of getFilesUnder(String path, FileFilter fileFilter)
public static List<File> getFilesUnder(String path, FileFilter fileFilter)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.util.*; public class Main { public static List<File> getFilesUnder(String path, FileFilter fileFilter) { File root = new File(path); List<File> files = new ArrayList<File>(); addFilesUnder(root, files, fileFilter); return files; }//from w w w .j a v a 2 s .c om private static void addFilesUnder(File root, List<File> files, FileFilter fileFilter) { if (!fileFilter.accept(root)) return; if (root.isFile()) { files.add(root); return; } if (root.isDirectory()) { File[] children = root.listFiles(); for (int i = 0; i < children.length; i++) { File child = children[i]; addFilesUnder(child, files, fileFilter); } } } }