Here you can find the source of getResourceInDirPackage(String packageName, String packagePath, final boolean recursive, List
private static void getResourceInDirPackage(String packageName, String packagePath, final boolean recursive, List<String> classes)
//package com.java2s; import java.io.File; import java.util.List; public class Main { private static void getResourceInDirPackage(String packageName, String packagePath, final boolean recursive, List<String> classes) { File dir = new File(packagePath); if (!dir.exists() || !dir.isDirectory()) { return; }/* ww w . j av a2 s. c o m*/ File[] dirfiles = dir.listFiles(); for (File file : dirfiles) { if (file.isDirectory()) { getResourceInDirPackage(packageName + "." + file.getName(), file.getAbsolutePath(), recursive, classes); } else { classes.add(packageName + "." + file.getName()); } } } }