File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes code throws FileNotFoundException access denied Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "code throws FileNotFoundException access denied" Watch "code throws FileNotFoundException access denied" New topic
Author

code throws FileNotFoundException access denied

Olivia Mayo
Greenhorn

Joined: May 11, 2003
Posts: 29
I got this code and tried it out in my servlet but I keep getting a FileNotFoundException and access is denied "dirName". Can someone help?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

The only problem with this code is the "catch" block, which swallows the exception and doesn't log any indicator of where the error happens; for testing, at least, it could log the stack trace.
Anyway, a FileNotFoundException means just that: a file doesn't exist. Figure out why your code thinks a file that does not exist does exist, and you'll have solved the problem.
In a servlet, it's likely that the problem is that you're wrong about where the "current directory" is, and that's the root of the problem. Sounds like your servlet doesn't have write access to the current directory, which is common. The servlet shouldn't try to create files there; it should have its own "scratch directory" to use.
[ July 18, 2003: Message edited by: Ernest Friedman-Hill ]

[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: code throws FileNotFoundException access denied
 
Similar Threads
Error performing inpage operation
Java RMC popup applet error
Writing a Recursive Descent Parser, I think I'm done, well almost?
Serialization Handing
Problem in copying JAR file