Егор Лебедев Егор Лебедев - 2 months ago 27
Java Question

Java: file not found exception

File file1 = new File("news1.txt");

This prints false, but file
is in directory, with that class.


This assumes that news1.txt is in the same folder as the class, calling this code. If you are using Eclipse, for example, this will look for the file in the root folder of the project, and not in the src folder. You should verify that the file is indeed in the right location.