Bug (old?) in ZipEntry?
Martin Egholm Nielsen
martin@egholm-nielsen.dk
Fri Sep 9 12:26:00 GMT 2005
Hi there,
I'm seing quite an odd thing (read: maybe a bug) with the
modification-dates returned from ZipEntry.
This may be an old bug fixed in a gcj version newer than my 3.4.3.
Nevertheless, I have the simple source given below that just enumerates
each entry in a zip file and prints out the modification date.
I'm using both WinZip and "zip" from (a recent) Cygwin.
When running the program with Sun's Java I get:
=== SUN ===
$ java -cp . men.zipdate.ZipDates fromzip.zip
ZipDates.java date: 1126260112000 Fri Sep 09 12:01:52 CEST 2005
$ java -cp . men.zipdate.ZipDates fromwinzip.zip
ZipDates.java date: 1126260114000 Fri Sep 09 12:01:54 CEST 2005
Hence, the same dates. As expected... However, when I try with GCJ I get:
=== GCJ ===
# ./zipdates fromzip.zip
ZipDates.java date: 313906034000 Thu Dec 13 03:07:14 GMT-01:00 1979
# ./zipdates fromwinzip.zip
ZipDates.java date: 1126270914231 Fri Sep 09 12:01:54 GMT-01:00 2005
That is, only the winzip-archive's entry-date is reported correctly.
The archives are identical to the ones used in the Sun test above...
But as I say, may an old bug?!
BR,
Martin Egholm
=== File: ZipDates.java ===
package men.zipdate;
import java.io.IOException;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class ZipDates
{
public static void main(String[] args) throws IOException
{
if (args.length < 1)
{
System.out.println("Missing filename argument...");
return;
} // if
else
{
ZipFile zf = new ZipFile(args[0]);
Enumeration entries = zf.entries();
while (entries.hasMoreElements())
{
ZipEntry entry = (ZipEntry) entries.nextElement();
System.out.println(entry.getName() + "\tdate: " + entry.getTime()
+ "\t" + new java.util.Date(entry.getTime()));
} // while
} // else
} // main
} // ZipDates
More information about the Java
mailing list