Java ClassPath Get getClassPath(String packageName, String name)

Here you can find the source of getClassPath(String packageName, String name)

Description

get Class Path

License

Open Source License

Declaration

public static File getClassPath(String packageName, String name) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

public class Main {
    private static final String ENCODING = "UTF-8";

    public static File getClassPath(String packageName, String name) {

        String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();
        try {/*from  w  w w .j  av  a2 s.  c  o  m*/
            path = URLDecoder.decode(path, ENCODING);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        File file = new File(path + getFilePath(packageName, name));
        return file;
    }

    private static String getFilePath(String packageName, String name) {
        String path = packageName.replaceAll("\\.", "/");
        return path + "/" + name;//"/" +
    }
}

Related

  1. getClasspath(ClassLoader classLoader)
  2. getClassPath(ClassLoader loader)
  3. getClasspath(ClassLoader loader)
  4. getClassPath(File dir)
  5. getClassPath(Object obj, boolean bOnlyPath)
  6. getClassPathAsString(ClassLoader classLoader)
  7. getClasspathDir(Class klass)
  8. getClasspathFile(Class clz)
  9. getClassPathFile(Class clazz)