コード例 #1
0
 public static File locationOf(Class clazz) {
   String path = clazz.getProtectionDomain().getCodeSource().getLocation().getPath();
   path = path.contains("!") ? path.substring(0, path.lastIndexOf('!')) : path;
   if (!path.isEmpty() && path.charAt(0) == '/') {
     path = "file:" + path;
   }
   try {
     return getRelativeFile(new File(new URL(path).toURI()), currentDir);
   } catch (Exception e) {
     Log.severe("", e);
     return getRelativeFile(new File(path), currentDir);
   }
 }