//将文件列表压缩成压缩包 public void zipFiles(List files, String zipFilePath) throws IOException { Log.e("测试====", "开始压缩文件===========" + zipFilePath); byte[] buffer = new byte[1024]; ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFilePath)); for (File file : files) { FileInputStream fis = new FileInputStream(file); out.putNextEntry(new ZipEntry(file.getName())); int len; while ((len = fis.read(buffer)) > 0) { out.write(buffer, 0, len); } out.closeEntry(); fis.close(); } out.close(); Log.e("测试====", "压缩文件完成=====22===========" + zipFilePath); }

将文件列表压缩成压缩包 fun zipFilesfiles ListFile zipFilePath String Loge测试====开始压缩文件===========+zipFilePath; val buffer = ByteArray1024 val out = ZipOutputStreamFileOutputStreamzipFileP

原文地址: https://www.cveoy.top/t/topic/jfsG 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录