public static void main(String[] args) throws Exception {
String filePath = "E://xx//xx.zip";
ZipFile zf = new ZipFile(filePath);
java.util.Enumeration zipEnum = zf.entries();
InputStream in = new BufferedInputStream(new FileInputStream(filePath));
while(zipEnum.hasMoreElements ()){
ZipEntry ze = (ZipEntry) zipEnum.nextElement();
if(ze.isDirectory()){
//为空的文件夹什么都不做
}else{
System.err.println("file:"+ze.getName()+"\nsize:"+ze.getSize()+"bytes\nCompressedSize:"+ze.getCompressedSize());
if(ze.getSize()>0){
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(
new InputStreamReader(zf.getInputStream(ze),"utf-8"),8192*10);
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
String str=sb.toString().trim();
str=new String(str.getBytes("utf-8"));
System.out.println(str);
System.out.println("数据:--"+sb.toString().trim());
br.close();
}
}
}
in.close();
}