Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4985614

Failure on calls to ZipFile constructor

XMLWordPrintable

    • b64
    • generic, x86
    • generic, windows_xp



      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
      ======================================================================

            sherman Xueming Shen
            rverabel Raghu Verabelli (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: