http://www.baidu.com/s?wd=java+zip&cl=3

解决方案 »

  1.   

    http://www.pconline.com.cn/pcedu/empolder/gj/java/0409/446639.html
      

  2.   

    你可以使用common里的zip工具,这个对中文的支持比较好
      

  3.   

    这是我写的
    将文件压缩成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();