将多个文件用zip打包
用法: 先用javac编译,后用java ZipCompress1 a.rpm b.rpm c.rpm, 最终打包成testm.zip文件

import java.util.*;
import java.util.zip.*;
import java.io.*;
public  class ZipCompress1 {
         public  static  void main(String[] args) {
                 try {
                        FileOutputStream f =  new FileOutputStream( "testm.zip");
                        ZipOutputStream out =  new ZipOutputStream( new DataOutputStream(f));
                         for ( int i = 0; i < args.length; i++) {
                                System.out.println( "Writing file " + args[i]);
                                DataInputStream in =
                                         new DataInputStream( new FileInputStream(args[i]));
                                out.putNextEntry( new ZipEntry(args[i]));
                                 int c;
                                 while ((c = in.read()) != -1)
                                        out.write(c);
                                in.close();
                        }
                        out.close();

                }  catch (Exception e) {
                        e.printStackTrace();
                }
        }
}