http://www.baidu.com/s?wd=java+zip&cl=3
解决方案 »
- jsp获取session时出错了 求大虾帮助!!
- hql的left join的时候出现:Path expected for join!
- Java中,List里面最多可以存储多少数据?有无上限?
- 求Spring IDE 2.0.6
- 在设计下载时出现了ClientAbortException: java.net.SocketException:
- 为什么csdn论坛好多人都不结帖????
- LookupDispatchAction
- easystruts插件问题
- 北京在新年期间有没有大型IT招聘会?
- Service层需不需要重新NEW?
- weblogic创建数据连接池不成功
- 请大家帮帮忙,我对Struts标签库的困惑
将文件压缩成ZIP
int code[]=new int[33];
for(int i=0;i<code.length;i++){
code[i]=1;
System.out.print("i="+code[i]);
}
String path=request.getRealPath("");//取得当前目录的路?
byte b[] = new byte[512];
ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(path+"/tempfile/test.zip"));
String args[]={path+"/tempfile/download_123.txt",path+"/tempfile/download_456.txt",path+"/tempfile/download_789.txt"};
for(int i = 0; i < args.length; i ++) {
InputStream in = new FileInputStream(args[i]);
ZipEntry e = new ZipEntry(args[i].replace(File.separatorChar,'/'));
zout.putNextEntry(e);
int len=0;
while((len=in.read(b)) != -1) {
zout.write(b,0,len);
}
zout.closeEntry();
// print(e);
}
zout.close();