java中怎么获得压缩文件的大小?需要获得压缩包里的每个文件的大小,求各位帮忙
答案:1 悬赏:60 手机版
解决时间 2021-03-06 14:32
- 提问者网友:爱唱彩虹
- 2021-03-06 05:47
java中怎么获得压缩文件的大小?需要获得压缩包里的每个文件的大小,求各位帮忙
最佳答案
- 五星知识达人网友:西风乍起
- 2021-03-06 06:45
import java.io.*;
import java.util.zip.*;
public class ZipEntriesDemo {
public static void main(String... args) throws IOException {
ZipInputStream zipIn = new ZipInputStream(new FileInputStream(args[0]));
ZipEntry zipEntry;
while ( (zipEntry = zipIn.getNextEntry()) != null ) {
zipIn.closeEntry();
if (!zipEntry.isDirectory()) {
String name = zipEntry.getName();
long size = zipEntry.getSize();
long compd = zipEntry.getCompressedSize();
System.out.printf("%s , size=%d, compressed size=%d
", name, size, compd);
}
}
zipIn.close();
}
}
import java.util.zip.*;
public class ZipEntriesDemo {
public static void main(String... args) throws IOException {
ZipInputStream zipIn = new ZipInputStream(new FileInputStream(args[0]));
ZipEntry zipEntry;
while ( (zipEntry = zipIn.getNextEntry()) != null ) {
zipIn.closeEntry();
if (!zipEntry.isDirectory()) {
String name = zipEntry.getName();
long size = zipEntry.getSize();
long compd = zipEntry.getCompressedSize();
System.out.printf("%s , size=%d, compressed size=%d
", name, size, compd);
}
}
zipIn.close();
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯