Java方法进行解压/生成有密码保护的压缩文件(zip格式)时间:2021-11-26 12:41:35参考地址:解压&&压缩文件+密码 /*** 2015-12-4 * DES:处理文件工具类* author:JiBaoLe */ public class FileUtils { /** * * @param srcfile 文件名数组 * @param zipfile 压缩后文件 */ public static void ZipFiles(java.io.File[] srcfile, java.io.File zipfile) { byte[] buf = new byte[1024]; try { ZipOutputStream out = new ZipOutputStream(new FileOutputStream( zipfile)); for (int i = 0; i < srcfile.length; i++) { FileInputStream in = new FileInputStream(srcfile[i]); out.putNextEntry(new ZipEntry(srcfile[i].getName())); int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } out.closeEntry(); in.close(); } out.close(); } catch (IOException e) { e.printStackTrace(); } }}