ITPUB??ì3
12月微软Hyper-V虚拟化沙龙主题征集
ITPUB论坛 » Java入门与认证版 » 文件下载问题!

新一届的微软MVP评选已经开始,欢迎各位推荐!

标题: 文件下载问题!
离线 crazylch01
一般会员



精华贴数 0
个人空间 0
技术积分 316 (6369)
社区积分 0 (761142)
注册日期 2006-2-13
论坛徽章:0
      
      

发表于 2006-6-14 11:42 
文件下载问题!

我写了一段程序实现了文件的下载功能,不过文件名全部为READ。DO请问这是怎么回事呀!该怎么解决呀!
String path=this.getServlet().getServletContext().getRealPath("/upload/"+file);

File f=new File(path);
long flength=f.length();
Long fsize=new Long(flength);
int size=fsize.intValue();
String fname=f.getName();
try{
FileInputStream in=new FileInputStream(f);
byte b[]=new byte[size];
in.read(b);
rsp.setContentType("application/";
                                        rsp.setHeader("content-Dispositon","fname="+fname+"";
                                        ServletOutputStream out=rsp.getOutputStream();
                                        out.write(b);
                                        out.close();
                                        in.close();
                                       
                                }catch(Exception e){e.getMessage();}


只看该作者    顶部
 
    

相关内容


CopyRight 1999-2006 itpub.net All Right Reserved.
北京皓辰广域网络信息技术有限公司. 版权所有
E-mail:Webmaster@itpub.net
京ICP证:010037号 联系我们 法律顾问