public class JarPath {
/**
* LOG 日志
*/
private static Logger LOG = Logger.getLogger(JarPath.class);
public static String getJarPath(){
String path = JarPath.class.getProtectionDomain().getCodeSource().getLocation().getFile();
path = ReadConfig.getUnixPath(path);
if(path.startsWith("/")){
path = path.substring(1);
}
if(path.endsWith("/")){
path = path.substring(0,path.length() - 1);
}
path = path.substring(0,path.lastIndexOf("/")+1);
path=path.replaceAll("%20"," ");
return path;
}
}
注:如果改成StringBuffer就更好了!!!!