获取Java项目的绝对根地址
public static String findProjectRootPath() {
/*
* This method in the jar package access path is not correct
*/
// RSAEncrypt encrypt = new RSAEncrypt();
// String path =
// encrypt.getClass().getResource("").toString().replace("file:/", "");
// path = path.substring(0, path.indexOf("live/target") + 5);
/*
* This method is based on the current file to obtain an absolute
* address
*
*/
return new File("").getAbsolutePath().replaceAll("\\\\", "//").concat("/");
};
获取Java项目的绝对根地址
最新推荐文章于 2021-08-02 22:51:54 发布