Get Modification Time of Zip Entry - Java File Path IO

Java examples for File Path IO:Zip File

Description

Get Modification Time of Zip Entry

Demo Code

import java.io.IOException;
import java.util.Date;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class Main {

  public static void main(String args[]) {
    try {/*from   www. java 2 s. c  o  m*/
      ZipFile zipFile = new ZipFile("c:/Folder/WebFiles.zip");

      Enumeration e = zipFile.entries();

      System.out.print("File Name");
      System.out.print("\t\t\t\tModification Time");

      while (e.hasMoreElements()) {
        ZipEntry entry = (ZipEntry) e.nextElement();

        String entryName = entry.getName();
        Date modificationTime = new Date(entry.getTime());

        System.out.print(entryName);
        System.out.print("\t\t\t\t" + modificationTime);
        System.out.print("\n");
      }
      zipFile.close();

    } catch (IOException ioe) {
      System.out.println("Error opening zip file" + ioe);
    }
  }

}

Result


Related Tutorials