Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

code throws FileNotFoundException access denied  RSS feed

 
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
Sheriff
Posts: 24217
38
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!