// 文件压缩
public static File zip(List<String> fileNames, String zipPath, String encoding) {
try {
FileOutputStream f = new FileOutputStream(zipPath);
ZipOutputStream out = new ZipOutputStream(new DataOutputStream(f));
// FIXME
out.setEncoding(encoding);
for (int i = 0; i < fileNames.size(); i++) {
String fileName = fileNames.get(i);
DataInputStream in = new DataInputStream(new FileInputStream(fileName));
String entryName = StringUtils.substringAfterLast(fileName, File.separator);
out.putNextEntry(new ZipEntry(entryName));
int c;
while ((c = in.read()) != -1) {
out.write(c);
}
in.close();
}
out.close();
return new File(zipPath);
} catch (Exception e) {
throw new RuntimeException(e);
}
}