Here you can find the source of getFileList(File dir, String regex)
private static ArrayList<String> getFileList(File dir, String regex) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; public class Main { private static ArrayList<String> getFileList(File dir, String regex) throws Exception { ArrayList<String> fileList = new ArrayList<String>(); File[] fs = dir.listFiles(); for (int i = 0; i < fs.length; i++) { if (fs[i].isDirectory()) { fileList.addAll(getFileList(fs[i], regex)); } else if (fs[i].isFile() && fs[i].getName().endsWith(regex)) { fileList.add(fs[i].getAbsolutePath()); }// w w w .jav a2 s . c o m } return fileList; } }