}
public static void zip(File[] files, String baseFolder, ZipOutputStream zos)
throws Exception {
// 输入
FileInputStream fis = null;
// 条目
ZipEntry entry = null;
// 数目
int count = 0;
for (File file : files) {
if (file.isDirectory()) {
// 递归
zip(file.listFiles(), file.getName() + File.separator, zos);
continue;
}
entry = new ZipEntry(baseFolder + file.getName());
// 加入
zos.putNextEntry(entry);
fis = new FileInputStream(file);
// 读取
while ((count = fis.read(buffer, 0, buffer.length)) != -1)
// 写入
zos.write(buffer, 0, count);
}
}