@SuppressWarnings("unchecked")
public static void unZipFileByOpache(org.apache.tools.zip.ZipFile zipFile??
String unZipRoot) throws Exception?? IOException {
java.util.Enumeration e = zipFile.getEntries();
System.out.println(zipFile.getEncoding());
org.apache.tools.zip.ZipEntry zipEntry;
while (e.hasMoreElements()) {
zipEntry = (org.apache.tools.zip.ZipEntry) e.nextElement();
InputStream fis = zipFile.getInputStream(zipEntry);
if (zipEntry.isDirectory()) {
} else {
File file = new File(unZipRoot + File.separator
+ zipEntry.getName());
File parentFile = file.getParentFile();
parentFile.mkdirs();
FileOutputStream fos = new FileOutputStream(file);
byte[] b = new byte[1024];
int len;
while ((len = fis.read(b?? 0?? b.length)) != -1) {
fos.write(b?? 0?? len);
}
fos.close();
fis.close();
}
}
}
public static void ZipFile(String zipFileName?? String inputFileName)
throws Exception {
org.apache.tools.zip.ZipOutputStream out = new org.apache.tools.zip.ZipOutputStream(
new FileOutputStream(zipFileName));
out.setEncoding("gbk");// ???????????????????????????????????????????????????
File inputFile = new File(inputFileName);
zip(out?? inputFile?? ""?? true);
System.out.println("zip done");
out.close();
}
public static void unZipFile(String unZipFileName?? String unZipPath)
throws Exception {
org.apache.tools.zip.ZipFile zipFile = new org.apache.tools.zip.ZipFile(
unZipFileName?? "gbk");
unZipFileByOpache(zipFile?? unZipPath);
System.out.println("unZip Ok");
}
}