Here you can find the source of getFiles(String path, String[] allowedExtension)
public static List<File> getFiles(String path, String[] allowedExtension)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { public static List<File> getFiles(String path, String[] allowedExtension) { List<File> r = new ArrayList<File>(); File rfolder = new File(path); if (rfolder.exists() && rfolder.isDirectory()) { File[] files = rfolder.listFiles(); for (File f : files) { if (isAllowedExtension(f.getName(), allowedExtension)) { r.add(f);/*w w w . ja v a2 s .c o m*/ } } } return r; } public static File[] listFiles(String path, String[] allowedExtension) { List<File> fs = getFiles(path, allowedExtension); return fs.toArray(new File[fs.size()]); } private static boolean isAllowedExtension(String fExt, String[] allowedExtension) { for (String ext : allowedExtension) { if (fExt.endsWith(ext)) return true; } return false; } }