This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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 ]