// 第一种:获取类加载的根路径
File f = new File(this.getClass().getResource("/").getPath());
// 获取当前类的所在工程路径; 如果不加“/” 获取当前类的加载目录
File f2 = new File(this.getClass().getResource("").getPath());
// 第二种:获取项目路径
File directory = new File("");// 参数为空
String courseFile = directory.getCanonicalPath();
// 第三种:
URL xmlpath = this.getClass().getClassLoader().getResource("");
// 第四种:
System.out.println(System.getProperty("user.dir"));
// 第五种:
System.out.println(System.getProperty("java.class.path"));