try {
String path = "E/a.zip";
ZipFile zf = new ZipFile(path,Charset.forName("gbk"));
Enumeration<? extends ZipEntry> zs = zf.entries();
while (zs.hasMoreElements()) {
ZipEntry ze = zs.nextElement();
//跳過目錄
if (!ze.isDirectory() && ze.getSize()>0 ) {
String name = ze.getName();
InputStream input = null;
//判斷文件是否包含關鍵字
if(name.contains("LTE")) {
//將文件讀入InputStream中
if(name.endsWith(".gz")) {
input = new GZIPInputStream(zf.getInputStream(ze));
}else if (name.endsWith(".zip")){
input = new ZipInputStream(zf.getInputStream(ze));
((ZipInputStream)input).getNextEntry();
}if(name.endsWith(".XML")) {
input = zf.getInputStream(ze);
}
//處理InputStream中的數據
decode(input);
} else{
//logger.info("文件有誤");
//return null;
}
}
}
zf.close();
} catch (IOException e) {
e.printStackTrace();
}