这是一个查看压缩文件的class不是压缩的会抛出例外,,参考一下吧import java.io.*;
import java.util.Enumeration;
import java.util.zip.*;public class zipview {
  public static void dump(ZipFile zf, ZipEntry ze)
    throws IOException
  {
    System.out.println(">>>>> " + ze.getName());
    InputStream istr = zf.getInputStream(ze);
    BufferedInputStream bis =
      new BufferedInputStream(istr);
    FileDescriptor out = FileDescriptor.out;
    FileOutputStream fos = new FileOutputStream(out);
    int sz = (int)ze.getSize();
    final int N = 1024;
    byte buf[] = new byte[N];
    int ln = 0;
    while (sz > 0 &&  // workaround for bug
      (ln = bis.read(buf, 0, Math.min(N, sz))) != -1) {
        fos.write(buf, 0, ln);
        sz -= ln;
     }
     bis.close();
     fos.flush();
   }   public static void main(String args[])
   {
     boolean dump_contents = false;
     int arg_indx = 0;
     ZipFile zf = null;     if (args.length >= 1 &&
         args[0].equals("-contents")) {
       dump_contents = true;
       arg_indx++;
     }
     if (arg_indx >= args.length) {
       System.err.println("usage: [-contents] file");
       System.exit(1);
     }     try {
       zf = new ZipFile(args[arg_indx]);
     }
     catch (ZipException e1) {
       System.err.println("exception: " + e1);
     }
     catch (IOException e2) {
       System.err.println("exception: " + e2);
     }     Enumeration list = zf.entries();
     while (list.hasMoreElements()) {
       ZipEntry ze = (ZipEntry)list.nextElement();
       if (!dump_contents || ze.isDirectory()) {
         System.out.println(ze.getName());
         continue;
      }
      try {
        dump(zf, ze);
      }
      catch (IOException e) {
        System.err.println("exception: " + e);
      }
    }
  }
}