求创建、读取一个zip文件的代码

解决方案 »

  1.   

    看看ZipInputStream,ZipOutputStream这2个类,不难写几句
        String fileName = "e:\\setupsql.chm";
        ZipOutputStream zop = new ZipOutputStream(new FileOutputStream("test.zip"));
        zop.putNextEntry(new ZipEntry(fileName));
        FileInputStream fs = new FileInputStream(fileName);    byte[] buf = new byte[1024];
        int len = 0;
        while ( (len = fs.read(buf)) != -1) {
          zop.write(buf, 0, len);
        }
        zop.close();
      

  2.   

    java.util.zip里面的类能否生成一个密码保护的zip文件?