Java reading txt.file - access denied?

Kristian picture Kristian · Oct 25, 2011 · Viewed 21.6k times · Source

I have created a txt file which I have saved in My Documents on my computer. I am trying to read the txt file through FileReader and BufferedReader. However, when I try to run the program I get the error message:

java.io.FileNotFoundException: <filelocation> (Access is denied)

Does anyone know what causes this, and how I might fix the problem? I have tried saving the document other places too, but I always get this message. I am sure the file path is correclty entered.

Answer

user207421 picture user207421 · Oct 26, 2011

java.io.FileNotFoundException: C:\Users\Kristian\Documents (Access is denied)

You are trying to read a directory, not a .txt file.