日期:2014-05-20  浏览次数:20790 次

求告手帮忙
java.io.FileNotFoundException: D:\Documents and Settings\Administrator\Workspaces\MyEclipse 8.6\struts1Project\WebRoot\chinaStamps (拒绝访问。)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
at com.sh.lw.action.ImageAction.upload(ImageAction.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
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 com.sh.lw.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:22)
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:127)
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:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)

我的磁盘上的文件夹和文件都是只读属性,系统是winxp,网上有些人说,只读属性只是个形式,没关系,但是我做一个文件上传的功能,却不能访问这个目录,拒绝访问,我试图改变只读属性,但是改了后,打开还是只读的,现在程序也测不了。烦啊,各位兄弟们帮忙看一下

------解决方案--------------------
只读应该没影响。
你的chinaStamps存在不?
------解决方案--------------------
at com.sh.lw.action.ImageAction.upload(ImageAction.java:111)

这段贴出来看看
------解决方案--------------------
你这代码有误呀! f是个目录。。。。。


FileInputStream fis = new FileInputStream(f);

好像只能读文件。。 不是目录
------解决方案--------------------
File f = new File(s)
你的file是个文件夹而不是文件,当然就会报FileNotFoundException

http://yin123.blog.51cto.com/882581/438653链接里面也是这个错。