Java获取压缩包文件列表
答案:1 悬赏:20
解决时间 2021-02-12 16:20
- 提问者网友:王者刀枪不入
- 2021-02-12 03:23
Java获取压缩包文件列表
最佳答案
- 二级知识专家网友:余生继续浪
- 2021-02-12 03:46
public static void main (String args[]) throws IOException {
ZipFile zf = new ZipFile("E:\\test.zip");
InputStream in = new BufferedInputStream(new FileInputStream("E:\\test.zip"));
ZipInputStream zin = new ZipInputStream(in);
ZipEntry ze;
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();
}
ZipFile zf = new ZipFile("E:\\test.zip");
InputStream in = new BufferedInputStream(new FileInputStream("E:\\test.zip"));
ZipInputStream zin = new ZipInputStream(in);
ZipEntry ze;
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();
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯