Here you can find the source of getPackageFolder(String packageName, ClassLoader classLoader)
private static File getPackageFolder(String packageName, ClassLoader classLoader) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.IOException; import java.net.URL; import java.util.Enumeration; public class Main { public static File getPackageFolder(String packageName) throws IOException { return getPackageFolder(packageName, Thread.currentThread().getContextClassLoader()); }/*from ww w. ja v a 2 s. com*/ private static File getPackageFolder(String packageName, ClassLoader classLoader) throws IOException { Enumeration<URL> resources = classLoader.getResources(packageName.replace('.', '/')); if (resources.hasMoreElements()) return new File(resources.nextElement().getFile()); return null; } }