Accepted answer

the path of the file is absolute to your project. in your case homework_one so if you want to access alice2.txt try "./alice2.txt" or for alice.txt ./src/com/abenson/hw0/three/alice.txt

 public static void main(string[] args) throws filenotfoundexception {
file tester = new file("./alice2.txt");  // or new file("./src/com/abenson/hw0/three/alice.txt");


scanner in = new scanner(tester);



whith new file("file.txt"); he try found the file on the racine of the project see here

he try found the blue file not the red


you took the right approach which is to print the absolute path. imo the only reasonable explanation is that you did not put enough attention to checking it. can you try to re-run it and compare the paths: the one printed and the one you see right clicking and checking file properties?

typically the output of the program will be on most setups: <your_workspace_path>\<your_project_path>\alice2.txt whereas you want <your_workspace_path>\<your_project_path>\src\fr\test\alice2.txt

Related Query

More Query from same tag