Java Class Loader getPackageFolder(String packageName, ClassLoader classLoader)

Here you can find the source of getPackageFolder(String packageName, ClassLoader classLoader)

Description

get Package Folder

License

Open Source License

Declaration

private static File getPackageFolder(String packageName, ClassLoader classLoader) throws IOException 

Method Source Code


//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;
    }
}

Related

  1. getFileFromClassLoader(String fileName)
  2. getFilesByPackgeName(String packageName, File _file, ClassLoader classLoader, List list)
  3. getJvmExtClassLoader()
  4. getLoadingDir(Class clazz)
  5. getManifest(ClassLoader cl, String extension)
  6. getParentClassLoader()
  7. getProjectClassLoader(IJavaProject javaProject)
  8. getProjectClassLoader(IJavaProject javaProject, ClassLoader parentClassLoader)
  9. getStreamForPath(ClassLoader loader, String path)