public class Test {
public static void main(String[] args) {
String zipFilePath = "/users/jerry/tmp/app-debug.zip";
read(zipFilePath);
}
private static void read(String zipFilePath) {
try {
ZipFile zipFile = new ZipFile(zipFilePath);
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
String name = entry.getName();
long compressedSize = entry.getCompressedSize();
long normalSize = entry.getSize();
String type = entry.isDirectory() ? "文件夹" : "文件";
System.out.print(name);
System.out.format("\t 类型:%s;压缩后大小:%d;原始大小:%d\n", type, compressedSize, normalSize);
}
zipFile.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}