我的项目结构:
/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)
波斯汪
相关分类