Here you can find the source of getFullPathByPkg(String pkg)
public static List<String> getFullPathByPkg(String pkg)
//package com.java2s; //License from project: Apache License import java.io.File; import java.net.URL; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> getFullPathByPkg(String pkg) { List<String> result = new ArrayList<>(); ClassLoader loader = Thread.currentThread().getContextClassLoader(); String packagePath = pkg.replace(".", "/"); URL url = loader.getResource(packagePath); File dir = new File(url.getPath()); StringBuilder str = new StringBuilder(); for (File f : dir.listFiles()) { str.append(pkg).append("."); str.append(f.getName().replace(".class", "")); result.add(str.toString());/*from w ww. j a v a2 s .com*/ str.delete(0, str.length()); } return result; } }