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");