我的項目結構:/myProject/ src/ main/... test/ resources/ myFile.txt當我將文件放在主項目文件夾下時:/myProject/ myFile.txt src/ main/... test/ resources/我的通話有效:String myFile = "myFile.txt";isFileThere(myFile);但是,當我將文件放入資源文件夾并構建其相對路徑時,它不起作用:String myFile = "myFile.txt";String fullPath = String.format("/src/test/resources/%s", myFile);isFileThere(fullPath);***java.io.FileNotFoundException: \src\test\resources\myFile.txt (The system cannot find the path specified) at java.base/java.io.FileInputStream.open0(Native Method)
添加回答
舉報
0/150
提交
取消