`
shihuan830619
  • 浏览: 574095 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

J2EE中应用Ant包压缩导出的Excel文件并提供下载

    博客分类:
  • J2SE
阅读更多
附件里的ZipCompressForAnt.java为压缩及解压缩的程序类;TestResultAction.java为导出、压缩、下载的全过程调用。(要注意两个文件里面的注释部分)

还有一个Java压缩zip示例.txt文件里面写的FileCompressor类, 这个文件是同事给的,我没试过, 如果有兴趣的可以试试看。


【注】: 附近里的代码只适用于Windows平台,如果想兼容Linux或其他操作系统,请参考
         下面代码进行自行修改:

String filePath = ctx.getRequest().getRealPath("/file/" + indexIp + "/");
		String downloadTmp = "download\\" + indexIp + "dl";
		int fileseparator = 0;   //标识Windows和Linux路径的斜杠,0为Windows系统的\,1为Linux系统的/
		if(System.getProperty("file.separator") != null){
			if(System.getProperty("file.separator").equals("/")){
				downloadTmp = "download/" + indexIp + "dl";
				fileseparator = 1;
			}
		}
		String download = filePath.substring(0, filePath.lastIndexOf("file")) + downloadTmp;
分享到:
评论
1 楼 sunandmoon 2010-11-21  
你好,能吧Struts.xml的配置贴出来看看嘛,谢谢

相关推荐

Global site tag (gtag.js) - Google Analytics