Your file should directly be under the project folder, and not inside any other sub-folder.
So, if your project folder is MyProject
, it's folder structure(not complete though) should be like: -
MyProject +- src +
| |
| +-- Your source file
+- file.txt
It should not be under src
folder.
Or, you can give the following path relative to the project folder to search for file in the src folder
: -
new File("src/file.txt");
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…