`
lili.cn
  • 浏览: 9597 次
  • 性别: Icon_minigender_2
  • 来自: 杭州
社区版块
存档分类
最新评论

xml文件生成压缩并且汇出

XML 
阅读更多
public void ZipFilesExport(final HttpServletResponse response ,StringBuffer[] xmlBuffer,String zipName,String[] xmlNames){
      response .setHeader("Content-Disposition","attachment;filename="+zipName);   
      response .setContentType("application/octet-stream");   
      ServletOutputStream   output=response .getOutputStream();  
      byte[] buf = new byte[1024];
      try {
              ZipOutputStream out = new ZipOutputStream(output);
                     for (int i = 0; i < xmlNames.length; i++) {
                        out.putNextEntry(new ZipEntry(xmlNames[i]));
                        out.write(xmlBuffer[i].toString().getBytes());
                        out.closeEntry();
                     }
             out.close();
             System.out.println("压缩完成.");
           }
           catch (IOException e) {
               e.printStackTrace();
            }
		  
}

 

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics