Here you can find the source of getAllFile(File directory, boolean descendIntoSubDirectories, String endofFile, String hiddenFileSuffix)
public static ArrayList<File> getAllFile(File directory, boolean descendIntoSubDirectories, String endofFile, String hiddenFileSuffix) throws IOException
//package com.java2s; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static ArrayList<File> getAllFile(File directory, boolean descendIntoSubDirectories, String endofFile, String hiddenFileSuffix) throws IOException { ArrayList<File> resultList = new ArrayList<File>(); File[] f = directory.listFiles(); for (File file : f) { if (file != null && file.getName().toLowerCase().endsWith(endofFile) && !file.getName().startsWith("tn_") && !file.getName().startsWith(hiddenFileSuffix)) { resultList.add(file);//from ww w. j a v a 2 s. c o m } if (descendIntoSubDirectories && file.isDirectory()) { ArrayList<File> tmp = getAllFile(file, true, endofFile, hiddenFileSuffix); if (tmp != null) { resultList.addAll(tmp); } } } if (resultList.size() > 0) return resultList; else return null; } public static ArrayList<File> getAllFile(File directory, boolean descendIntoSubDirectories, Pattern pattern, String hiddenFileSuffix) throws IOException { ArrayList<File> resultList = new ArrayList<File>(); File[] f = directory.listFiles(); Matcher matcher = null; for (File file : f) { matcher = pattern.matcher(file.getName().toLowerCase().trim()); if (file != null && matcher.find() && !file.getName().startsWith("tn_") && !file.getName().startsWith(hiddenFileSuffix)) { resultList.add(file); } if (descendIntoSubDirectories && file.isDirectory()) { ArrayList<File> tmp = getAllFile(file, true, pattern, hiddenFileSuffix); if (tmp != null) { resultList.addAll(tmp); } } } if (resultList.size() > 0) return resultList; else return null; } }