/**
-
文件解压缩,一个压缩包中可能包含多个文件和文件夹,解压缩需要对文* 件和文件夹分别解压缩。
*/
public static void unzip(String zipFilePath,String unzipPath)throws IOException{
try{
File unzipDir = new File(unzipPath);
if(unzipDir.exists()){
unzipDir.delete();
}
ZipFile zip = new ZipFile(zipFilePath);
Enumeration<? extends ZipEntry> zipEntries = zip.entries();
while (zipEntries.hasMoreElements()){
ZipEntry zipEntry = zipEntries.nextElement();
String pathName = unzipDir.getPath()+File.separatorChar+zipEntry.getName();
if(zipEntry.isDirectory()){
new File(pathName).mkdir();
}else {
InputStream input;
input = zip.getInputStream(zipEntry);
OutputStream out = new FileOutputStream(pathName);
int temp = 0;
while ((temp = input.read())!=-1){
out.write(temp);
}
input.close();
out.close();
}
}
if(zip!=null){
zip.close();
}
}catch (IOException e){}
}