试试这个
String filePath = new File("").getAbsolutePath();filePath.concat("path to the property file");因此,新文件指向创建路径,通常是项目主文件夹。
[编辑]
正如@cmc所说,
String basePath = new File("").getAbsolutePath(); System.out.println(basePath); String path = new File("src/main/resources/conf.properties") .getAbsolutePath(); System.out.println(path);两者都赋予相同的值。



