This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
FileNotFoundException would be better named CantAccessFileException. It addition to the file actually not being found (which you say is not the case), it might mean a permission problem (the Java program has no access rights), or maybe the file is still open by another process.
Joined: Mar 05, 2006
If it's a file permission problem, do you know any workaround?
If it is a permissions problem, the "workaround" is to ask the owner of the file to change its permissions so you can read it. But that's probably you, and it probably isn't a permissions problem at all. It is maybe the problem where you don't understand the concept "current working directory".
Your code tries to look for the file in the current working directory, since you provide only the file's name and no path information. You seem to be assuming that your current working directory is the one where your Java source code is stored. This is not necessarily the case. It is whatever you set it to be before running the class. Or whatever your IDE set it to, if you are not running the class from the command line.