Here you can find the source of getFiles(String realpath, List
public static List<java.io.File> getFiles(String realpath, List<File> files, String[] fileType)
//package com.java2s; import java.io.File; import java.util.List; public class Main { public static List<java.io.File> getFiles(String realpath, List<File> files, String[] fileType) { File realFile = new File(realpath); if (realFile.isDirectory()) { File[] subfiles = realFile.listFiles(); for (File file : subfiles) { if (file.isDirectory()) { getFiles(file.getAbsolutePath(), files, fileType); } else { if (isFileType(file.getName(), fileType)) { files.add(file); }// w w w . j a v a 2s .com } } } return files; } public static boolean isFileType(String fileName, String[] typeArray) { for (String type : typeArray) { if (fileName.toLowerCase().endsWith(type)) { return true; } } return false; } }