java获取当前路径的几种 方法:
String property = System.getProperty("user.dir");//获取当前项目路径
System.out.println(property);
File file=new File(".");
try {
String canonicalPath = file.getCanonicalPath();//相对路径
String ab=file.getAbsolutePath();//绝对路径
System.out.println(canonicalPath);
System.out.println(ab);
} catch (IOException e) {
e.printStackTrace();
}
//通过类取得路径
String path = Test1.class.getResource("/").getPath();
System.out.println(path);