java.io.FileNotFoundException: the system cannot find the file specified

Put the word.txt directly as a child of the project root folder and a peer of src Project_Root src word.txt Disclaimer: I’d like to explain why this works for this particular case and why it may not work for others. Why it works: When you use File or any of the other FileXxx variants, you are looking for a file … Read more

Java says FileNotFoundException but file exists

There are a number situation where a FileNotFoundException may be thrown at runtime. The named file does not exist. This could be for a number of reasons including: The pathname is simply wrong The pathname looks correct but is actually wrong because it contains non-printing characters (or homoglyphs) that you did not notice The pathname is relative, … Read more

JAVA + try catch(FileNotFoundException e) going in catch(Exception e)?

It’s also possible that the specific issue you’re having isn’t a FileNotFoundException. By using the “Exception” in a catch block (which is the parent class to all Exceptions) this is effectively a “catch all”, since it will run if there is an `Exception or any of its subclasses thrown. Try the following change: … catch … Read more