File dir = new File(dest + File.separator + zn.getName());
if (!dir.exists())
dir.mkdirs();
} else {
// 如果条目是文件(如果父路径不存在,就创建父路径),将条目从zip流中读出,并写出文件输出流
File f = new File(dest + File.separator + zn.getName());
File dir = f.getParentFile();
if (!dir.exists())
dir.mkdirs();
bos = new BufferedOutputStream(new FileOutputStream(f));
int i = 0;
while ((i = zis.read(BUFFER_DATA)) != -1) {
bos.write(BUFFER_DATA,0,i);
}
}
}
} finally {
if (bos != null)
bos.close();
if (zis != null)
zis.close();
}
}
public static void main(String[] args) {
try {
unZip(“E:/java/a.zip”,“E:/sql”);
} catch (IOException e) {
e.printStackTrace();
}
}
}