集册 Java实例教程 获取压缩条目的未压缩大小

获取压缩条目的未压缩大小

欢马劈雪     最近更新时间:2020-01-02 10:19:05

422
获取压缩条目的未压缩大小


import java.io.IOException;

import java.util.Enumeration;

import java.util.zip.ZipEntry;//from N o w J a v a . c o m

import java.util.zip.ZipFile;


public class Main {


  public static void main(String args[]) {

    try {

      ZipFile zipFile = new ZipFile("c:/Folder/WebFiles.zip");


      Enumeration e = zipFile.entries();


      System.out.print("File Name");

      System.out.print("\t\tUncompressed Size");

      System.out.println("\t\tCompressed Size");

      while (e.hasMoreElements()) {

        ZipEntry entry = (ZipEntry) e.nextElement();

        String entryName = entry.getName();

        long originalSize = entry.getSize();

        long compressedSize = entry.getCompressedSize();/**来自 时 代      J a v a   公   众 号 - nowjava.com**/


        System.out.print(entryName);

        System.out.print("\t\t" + originalSize);

        System.out.print("\t\t" + compressedSize
展开阅读全文