/**
* 获取项目所在路径(包括jar)
*
* @return
*/
public static String getProjectPath() {
java.net.URL url = UrlTest.class.getProtectionDomain().getCodeSource().getLocation();
String filePath = null;
try {
filePath = java.net.URLDecoder.decode(url.getPath(), "utf-8");
} catch (Exception e) {
e.printStackTrace();
}
if (filePath.endsWith(".jar"))
filePath = filePath.substring(0, filePath.lastIndexOf("/") + 1);
java.io.File file = new java.io.File(filePath);
filePath = file.getAbsolutePath();
return filePath;
}
获取项目所在路径,包括jar包
最新推荐文章于 2024-04-15 22:00:41 发布