posts - 35,  comments - 6,  trackbacks - 0
if (actflag.equals("download")) {
    saDoc= this.getDocumentAddService().execute(parentCode);
    
    OutputStream out = servletResponse.getOutputStream();
    String name = saDoc.getDocumentName();
    String nameISO = new String(name.getBytes("gb2312"), "iso-8859-1");
    // http http://www.faqs.org/rfcs/rfc2183.html
    servletResponse.setHeader("Content-Disposition", "attachment; filename=\""
      + nameISO + "\"");
    servletResponse.setHeader("Content-Length", String.valueOf(saDoc.getDocumentSize()));
    //BLOB blob = (BLOB) domain.getInformationContent();
    //InputStream in = blob.getBinaryStream();
    
    String path=saDoc.getDocumentSrc();
    path= path.replace('/','\\');
       String url=servletRequest.getRealPath("\\")+path+"\\"+saDoc.getDocumentName();  
    File file=new File(url);
    InputStream in =new FileInputStream(file);
    int count = 0;
    try {
     byte[] data = new byte[8192];
     while ((count = in.read(data)) != -1) {
      out.write(data, 0, count);
     }
    } finally {
     if (in != null) {
      in.close();
     }
     if (out != null) {
      out.close();
     }
    }    
    
    return null;
posted on 2007-04-17 13:46 NG 阅读(137) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 
<2007年4月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

常用链接

留言簿(1)

随笔档案(35)

文章分类(5)

文章档案(2)

新闻档案(5)

java link

搜索

  •  

最新评论

阅读排行榜

评论排行榜