[compress] Problem setting ZipEntry extended timestamps

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[compress] Problem setting ZipEntry extended timestamps

Luís Filipe Nassif
 Hi,

I am trying to create a zip file saving its entries accessTime and
CreationTime, but when I open the zip file with 7zip, those dates are not
shown, only modifiedTime. I am using compress-1.16.1. Sample code below
(without exception handling):

             FileOutputStream fos = new FileOutputStream("F:\\test.zip");
            ZipArchiveOutputStream zaos = new ZipArchiveOutputStream(fos);

            ZipArchiveEntry entry = new ZipArchiveEntry("file.txt");

            entry.setLastModifiedTime(FileTime.fromMillis(System.
currentTimeMillis()));
            entry.setLastAccessTime(FileTime.fromMillis(System.
currentTimeMillis()));
            entry.setCreationTime(FileTime.fromMillis(System.
currentTimeMillis()));

            zaos.putArchiveEntry(entry);

            byte[] buf = "content".getBytes("UTF-8");
            zaos.write(buf, 0, buf.length);

            zaos.closeArchiveEntry();

            zaos.close();

Any idea why it does not work?

Thanks,
Luis