读取压缩包的内容 不解压
作者:互联网
public class ZhiJieDuQu {
public static void main(String[] args) {
try {
ZhiJieDuQu.readZipFile(“D:\aaaaaaaaaaaaaaaaaaaaaaa\o1002-20151212103320-w3yc13e9.zip”);
} catch (Throwable e) {
e.printStackTrace();
}
}
public static void readZipFile(String file) throws Exception {
ZipFile zf = new ZipFile(file);
InputStream in = new BufferedInputStream(new FileInputStream(file));
ZipInputStream zin = new ZipInputStream(in);
ZipEntry ze;
List list = new ArrayList();
while ((ze = zin.getNextEntry()) != null) {
if (ze.isDirectory()) {
} else {
System.err.println(“file - " + ze.getName() + " : "
+ ze.getSize() + " bytes”);
long size = ze.getSize();
if (size > 0) {
BufferedReader br = new BufferedReader(
new InputStreamReader(zf.getInputStream(ze)));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
}
System.out.println();
}
}
zin.closeEntry();
}
}
标签:解压,读取,ze,System,file,zin,new,压缩包,String 来源: https://blog.csdn.net/weixin_43736692/article/details/90288792