压缩文件或目录
public static void zip(String src,String dest) throws IOException {
ZipOutputStream out = null;
try {
File fileOrDirectory= new File(src);
File outFile= new File(dest);
if (!outFile.exists()){
File parentfile=outFile.getParentFile();
if (!parentfile.exists()){
parentfile.mkdirs();
}
}
out = new ZipOutputStream(new FileOutputStream(outFile));
if (fileOrDirectory.isFile()){
zipFileOrDirectory(out,fileOrDirectory, "");
} else {
File[]entries = fileOrDirectory.listFiles();
for (int i= 0; i < entries.length;i++) {
zipFileOrDirectory(out,entries[i],fileOrDirectory.getName()+"/");
}
}
}catch(IOException ex) {
ex.printStackTrace();
}finally{