Java Utililty Methods Class Path

List of utility methods to do Class Path

Description

The list of methods to do Class Path are organized into topic(s).

Method

StringgetPath(String name, Class relativeTo)
get Path
return getFile(name, relativeTo).getAbsolutePath();
StringgetProgramRootPath(Class clazz)
get Program Root Path
try {
    return java.net.URLDecoder
            .decode(getClassPathFile(clazz).getParentFile().getParentFile().getAbsolutePath(), "UTF-8");
} catch (Exception e) {
    e.printStackTrace();
    return "";
StringgetRootAbsolutePathname(final Class clazz)
get Root Absolute Pathname
return getClassAbsolutePathname(clazz).replace(getClassRelativePathname(clazz), "");
StringgetRunClassAllPath(Object obj)
get Run Class All Path
Object currClass = obj;
String name = currClass.getClass().getSimpleName();
name += ".class";
URL clazzUrl = currClass.getClass().getResource(name);
String clazzStr = clazzUrl.getPath();
try {
    clazzStr = java.net.URLDecoder.decode(clazzStr, "UTF-8");
} catch (UnsupportedEncodingException e) {
...
StringgetSystemLibraryPath(Class locatorClass, String subDir)
get System Library Path
String name = locatorClass.getCanonicalName();
name = "/" + name.replace('.', '/') + ".class";
URL classUrl = locatorClass.getResource(name);
if (classUrl != null && classUrl.getProtocol().equals("file")) {
    String initializerPath = classUrl.getFile();
    initializerPath = getSystemLibraryPath(initializerPath, name, subDir);
    try {
        initializerPath = URLDecoder.decode(initializerPath, System.getProperty("file.encoding"));
...