Here you can find the source of getFilesByExt(String dirName, String ext)
public static File[] getFilesByExt(String dirName, String ext)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { private static String extension; public static File[] getFilesByExt(String dirName, String ext) { File dir = new File(dirName); extension = ext;//from www . j av a 2 s . c om return dir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String fileName) { return fileName.endsWith(extension); } }); } }