This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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
subject: FileNotFoundException - Access is denied
It's not a secret anymore!