htkhtk
htkhtk

Reputation: 131

File works in Java 1.5 but not in Java 7 (java.io.FileNotFoundException Permission Denied)

I have a file that I'm trying to access. When I accessed it in Java 1.5 it was fine. I have since upgraded to Java 7 and now I am getting a java.io.FileNotFoundException Permission Denied error.

java.io.FileNotFoundException: /folder/test.xml (Permission denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
at java.io.FileOutputStream.<init>(FileOutputStream.java:104)
at SerializeUtil.write(Unknown Source)

It is actually trying to write to the file using an XMLEncoder

XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(filename)));
encoder.writeObject(object);
encoder.close();

Upvotes: 1

Views: 1881

Answers (1)

user650749
user650749

Reputation: 182

If you are under Unix/Linux, try the following command under the user you running java $ touch /folder/test.xml

If your file is sitting on other locations(for example /home/AAA/folder/test.xml), replace the above path.

The idea is to test if your current user can write the file

Upvotes: 1

Related Questions