把文件打包到压缩包里
public void zip (String... files) throws IOException {
//创建文件打包流对象 ZipOutputStream zos = new ZipOutputStream(new FileOutputStream("d:\eee.zip")); for (String file : files) {
//内容描述 ZipEntry zipEntry = new ZipEntry(file); zos.putNextEntry(zipEntry);
//创建文件输入流 FileInputStream fis = new FileInputStream(file); int c; while ((c = fis.read()) > 0) { zos.write(c); } fis.close(); } zos.close(); }