File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes FileNotFoundException - Access is denied Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "FileNotFoundException - Access is denied" Watch "FileNotFoundException - Access is denied" New topic

FileNotFoundException - Access is denied

kamilla miesak
Ranch Hand

Joined: Mar 06, 2001
Posts: 30
I keep getting FileNotFoundException - Access is denied - when i'm trying to create and print to a file located in user's current working directory.
The same code works fine if I explicitly specify already existing folder i.e. c:\temp\test.txt (the new file gets created and contents are added to it). What might me causing the problem?
Thanks in advance for all the ideas!
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
I'm not sure what's going on. How exactly are you attempting to create the new file? I suggest something like the following:

The getAbsolutePath() is useful because often people turn out to not be in the directory they think they are (depending on how they invoked the java command).
[ July 15, 2002: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: FileNotFoundException - Access is denied
It's not a secret anymore!