aspose file tools*
The moose likes Java in General and the fly likes Getting java.io.FileNotFoundException:(The system cannot find the file specified) error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Getting java.io.FileNotFoundException:(The system cannot find the file specified) error" Watch "Getting java.io.FileNotFoundException:(The system cannot find the file specified) error" New topic
Author

Getting java.io.FileNotFoundException:(The system cannot find the file specified) error

J Lalit
Greenhorn

Joined: May 19, 2008
Posts: 15
Hi,

I havce craeted a servlet to download a file from web & store it locally.Here is my code




But when i am running this program,it is opening pop up & asking either to open the file or save it.On any of the option,i am getting this error at my server console


Aug 19, 2009 8:00:48 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet TestAction threw exception
java.io.FileNotFoundException: C:\Documents and Settings\Jangral\My Documents\ContentAdding_PDF_Attachment.pdf (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at TestAction.processRequest(TestAction.java:61)
at TestAction.doPost(TestAction.java:115)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:595)





Can anyone tell mne what more i need to do as i want to save this file with the same name locally on my machine.

Thanks & Regards,
lalit


Thanks & Regards
J Lalit.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The issue seems pretty well quantified by the exception:
The machine wrote:
java.io.FileNotFoundException: C:\Documents and Settings\Jangral\My Documents\ContentAdding_PDF_Attachment.pdf (The system cannot find the file specified)

My first assumption would be that you're missing a path separator.
J Lalit
Greenhorn

Joined: May 19, 2008
Posts: 15
Hi,

Thanks for reply.It may be the case that i need to create the file with the same name at the given location prior to saving the file??If so,can you please tell me how to achieve that.Or should i follow some other approach??
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18906
    
    8

J Lalit wrote:It may be the case that i need to create the file with the same name at the given location prior to saving the file??If so,can you please tell me how to achieve that.Or should i follow some other approach??


I don't understand what that means. I believe what David was suggesting was simply that the file name you use should be

instead of


I agree that it looks like you forgot to insert the backslash here:


However I would have used the File constructor which takes two strings, so that I wouldn't have to mess about with that sort of thing:
J Lalit
Greenhorn

Joined: May 19, 2008
Posts: 15
Hi Again,

So sorry for that stupid mistake.I will try once more.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting java.io.FileNotFoundException:(The system cannot find the file specified) error