Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

code throws FileNotFoundException access denied

 
Olivia Mayo
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic