public static void unzip1String zipName, String temPath) throws IOException {
ZipFile zip = new ZipFilenew FilezipName),Charset.forName"UTF-8"));
String zipName1 = zip.getName).substringzip.getName).lastIndexOf"\") + 1, zip.getName).lastIndexOf"."));
System.out.printlnzipName1);
String temp = temPath + "/" + zipName1 + System.currentTimeMillis);
File filePath = new Filetemp);
if !filePath.exists)) {
filePath.mkdirs);
}
for Enumeration<ZipEntry> zipEntrys = Enumeration<ZipEntry>) zip.entries); zipEntrys.hasMoreElements);) {
ZipEntry entry = zipEntrys.nextElement);
String name = entry.getName);
System.out.printlnname);
InputStream is = zip.getInputStreamentry);
String outputPath = temp + "/" + name).replaceAll"\*", "/");
//判断文件路径是否存在
File file = new FileoutputPath.substring0, outputPath.lastIndexOf"/")));
if !file.exists)) {
file.mkdirs);
}
if new FileoutputPath).isDirectory)) {
continue;
}
FileOutputStream os = new FileOutputStreamoutputPath);
byte[] buf = new byte[1024];
int len = 0;
whilelen = is.readbuf)) != -1) {
os.writebuf, 0, len);
}
os.close);
is.close);
}
System.out.println"解压成功。。。。");
}
public static void mainString[] args) {
String dir = "E:/test";
String zipName = "E:/test/zhangsan.zip";
String tempPath = "E:/zip";
// unzipdir, zipName, tempPath);
File file = new FilezipName);
try {
// unZipFilesfile, tempPath);
// unzip1zipName, tempPath);
System.out.printlninvertOrder123569));
} catch Exception e) {
// TODO Auto-generated catch block
e.printStackTrace);
}
}