Here you can find the source of getFileList(File file, String[] suffixs)
public static List<File> getFileList(File file, String[] suffixs)
//package com.java2s; //License from project: Apache License import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { public static List<File> getFileList(File file, String[] suffixs) { return getFileList(file, new ArrayList<File>(), suffixs, null, null); }//from ww w . j ava 2s . c o m public static List<File> getFileList(File file, String[] suffixs, String[] nameMatche, String[] nameNotMatche) { return getFileList(file, new ArrayList<File>(), suffixs, nameMatche, nameNotMatche); } public static List<File> getFileList(File file, List<File> fileList, String[] suffixs) { return getFileList(file, fileList, suffixs, null, null); } public static List<File> getFileList(File file, List<File> fileList, String[] suffixs, String[] nameMatche, String[] nameNotMatche) { if (file.getAbsolutePath().contains(".svn")) return fileList; if (file.isFile()) { String filename = file.getName(); boolean isNameRight = false; if (nameMatche != null && nameMatche.length > 0) { for (String str : nameMatche) { if (filename.toLowerCase().contains(str.toLowerCase())) { isNameRight = true; break; } } } else { isNameRight = true; } if (isNameRight) { if (nameNotMatche != null && nameNotMatche.length > 0) { for (String str : nameNotMatche) { if (filename.toLowerCase().contains(str.toLowerCase())) { isNameRight = false; break; } } } } if (isNameRight) { if (suffixs == null || suffixs.length == 0) { fileList.add(file); } else { int index = filename.lastIndexOf("."); if (index != -1) { boolean isright = false; String suffix = filename.substring(index, filename.length()); for (String str : suffixs) { if (suffix.equalsIgnoreCase(str)) { isright = true; break; } } if (isright) { fileList.add(file); } } } } } else if (file.isDirectory()) { File[] fs = file.listFiles(); for (File f : fs) { getFileList(f, fileList, suffixs, nameMatche, nameNotMatche); } } return fileList; } }