Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ZipEntry Problem on WinNT and Win2000

John Browne
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been using the Zip classes in the standard JDK for several years and have had no problems with it. However, my use of it was limited to compressing files, setting the mod date on each file archived. Recently, I had need to make use of some of the additional data fields that can be set on a ZipEntry. (btw, i'm working in Windows NT). It seems that some of these do not work as documented and I'm wondering if you've had any experience with these problems.
For example, if I set a comment with setComment(), a subsequent read of the comment with getComment() (upon serializing the archived file back in again) always yields NULL. If I try to set Size or Crc they are always -1 on subsequent read with the get methods.
Even more peculiar is setTime and getTime. If I setTime with a typical mod time of a file in my environment all is well on subsequent get of the time. If I try to set the time to the epoch ( 0) it sets the time to 1/1/1980 instead of 1/1/1970. Very odd. It's as if the zlib classes use a different time epoch than the standard java date classes.
The one that works is setExtra and getExtra. Those work as documented.
I've tried this (again always on WinNT or Win2000) with either code embedded in my application or stand alone test classes. I'm following the canonical code of creating a ZipEntry, setting the attributes, doing a putNextEntry and then writing the content.
Are you aware of these pecularities in the Windows version of the zlib classes?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic