Skip to content

Instantly share code, notes, and snippets.

@chatman
Created July 22, 2013 13:26
Show Gist options
  • Save chatman/6053783 to your computer and use it in GitHub Desktop.
Save chatman/6053783 to your computer and use it in GitHub Desktop.
import java.util.*;
import java.util.zip.*;
import java.io.*;
import java.util.Enumeration;
import java.util.zip.ZipFile;
import java.util.zip.ZipEntry;
public class ZipGetMethod {
public static void main(String[] args) {
String file = "moby.zip";
try {
ZipFile zipfile = new ZipFile(file);
Enumeration e = zipfile.entries();
while (e.hasMoreElements()) {
ZipEntry zipentry = (ZipEntry) e.nextElement();
String entryName = zipentry.getName();
Date lastModify = new Date(zipentry.getTime());
long uncomSize = zipentry.getSize();
long comSize = zipentry.getCompressedSize();
if ((zipentry.getMethod()) == ZipEntry.STORED) {
System.out.println("The entry Nmae " + entryName
+ " was stored at " + lastModify);
System.out.println("with a size of " + uncomSize
+ " bytes");
System.out.println(" ");
} else if ((zipentry.getMethod()) == ZipEntry.DEFLATED) {
System.out.println("The entry Nmae " + entryName
+ " was deflated at " + lastModify);
System.out.println("Uncompressed size of entry : "
+ uncomSize + " bytes");
System.out.println("Compressed size of entry : " + comSize
+ " bytes");
System.out.println(" ");
} else {
System.out.println("The entry Nmae " + entryName
+ " was compressed, but method name not specified "
+ lastModify);
System.out.println("Uncompressed size of entry : "
+ uncomSize + " bytes");
System.out.println("Compressed size of entry : " + comSize
+ " bytes");
}
}
} catch (IOException ex) {
System.out.println("IOException is : " + ex);
}
}
}
@chatman
Copy link
Author

chatman commented Jul 22, 2013

Produces the following output on FOCUS-4685's moby.zip.

IOException is : java.util.zip.ZipException: invalid CEN header (bad compression method)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment