Java Class Path getClassAbsolutePath(Class c)

Here you can find the source of getClassAbsolutePath(Class c)

Description

get Class Absolute Path

License

Apache License

Declaration

public static String getClassAbsolutePath(Class<?> c) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

public class Main {
    public static String getClassAbsolutePath(Class<?> c) {
        //ArrayUtil.class.getClass().getResource("/").getPath();
        String filePath = c.getProtectionDomain().getCodeSource().getLocation().getFile();
        try {/*from  w w  w  . ja v a2  s.c  om*/
            return URLDecoder.decode(filePath, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            return null;
        }
    }
}

Related

  1. getAbsolutePath(Class theClass, String path)
  2. getAbsolutePath(final Class clazz, final String relative)
  3. getApplicationPath(Class cls)
  4. getAppPath(Class clazz)
  5. getClass(String parentPath, String className)
  6. getClassBasePath(Class aClass)
  7. getClassFilePath(Class clazz)
  8. getClassFilePath(Class clazz)
  9. getClassFilePath(Class clazz)