Here you can find the source of getResourcesFromDirectory(File resource, Pattern pattern)
private static List<URL> getResourcesFromDirectory(File resource, Pattern pattern) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; public class Main { private static List<URL> getResourcesFromDirectory(File resource, Pattern pattern) throws IOException { ArrayList<URL> urls = new ArrayList<>(); final File[] fileList = resource.listFiles(); if (fileList == null) return urls; for (final File file : fileList) { if (file.isDirectory()) { urls.addAll(getResourcesFromDirectory(file, pattern)); } else { final String fileName = file.getCanonicalPath(); if (pattern.matcher(fileName).matches()) { urls.add(new URL(resource + "/" + fileName)); }//w w w .j av a 2 s. com } } return urls; } /** * Check if the argument is a directory. */ public static boolean isDirectory(String dir) { return (new File(dir)).isDirectory(); } }