目录"/>
获取当前jar包目录
获取当前jar包所在目录,(没出现过空指针异常的情况)。
public static String getPath(){java.URL url = Main.class.getProtectionDomain().getCodeSource().getLocation();String path = null;try {path = java.URLDecoder.decode(url.getPath(), "utf-8");} catch (Exception e) {e.printStackTrace();}int lastIndex = path.lastIndexOf("/")+1;path = path.substring(0, lastIndex);return path;}
更多推荐
获取当前jar包目录
发布评论