Name: rv122619 Date: 01/29/2004
When we make our spk files on VMS, they get their sizes rounded up to the nearest 512 byte boundary. This is not conducive with Java's idea of a Zip. According to the Java code, I think it says you aren't allowed to have a rounded off file like that. There is a line of code when looking for the end header that says:
if (endpos + ENDHDR + clen == len) {
/* Found END header */
Where len is the length of the file, endpos is the position of the end header signature, ENDHDR is the length of the end header and clen is the length of the comment. There is no comment in this file.
import java.util.zip.*;
public class ZTest{
private void readIt()
{
try
{
ZipFile z = new ZipFile("c:\\orig.zip");
System.out.println("The constructor worked successfully.");
ZipEntry zipentry = (ZipEntry) z.getEntry("PackageMetaData");
if (zipentry != null)
{
System.out.println("We have the package metadata.");
byte[] extraBytes = zipentry.getExtra();
if (extraBytes != null)
{
System.out.println("We have the extra info, length=" + extraBytes.length);
}
else System.out.println("Extra bytes are null.");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
ZTest sample = new ZTest();
sample.readIt();
System.exit(0);
}
}
Run against a zip file
======================================================================
- duplicates
-
JDK-4988969 ZipFile should provide better diagnostics when opening a corrupt ZIP file
-
- Closed
-
- relates to
-
JDK-4776464 ZipFile refuses to open valid ZIP files.
-
- Resolved
-