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

ZipOutputStream should have a copyEntry method

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P5 P5
    • None
    • 1.1.3
    • core-libs
    • Fix Understood
    • x86
    • windows_nt



      Name: rm29839 Date: 10/13/97


      In working with JAR files using java.util.zip
      classes, one glaring thing comes to mind. When
      making a new zip file, it would be nice (and faster)
      to have a copy method on the ZipOutputStream that
      uses a ZipEntry as a reference. From an API standpoint,
      the application can reference the entry, make a determination
      as to whether or not to output the entry from one zip file
      to another and simply use the copyEntry() to move it from one
      file to another. This would also be faster than
      the application decompressing the data (if it's ZipEntry.DEFLATED)
      and subsequently recompressing it via a write method. The following
      outlines what I'm talking about..

      You have to do this now...

      ZipInputStream foo = new ZipInputStream(..);
      ZipOutputStream out = new ZipOutputStream(..);
      ZipEntry entry;

      while(true)
      {
        try {entry = foo.getNextEntry();} catch (IOException e) {break;}
        if(entry == null)
           break;
        if(keepEntry(entry))
        {
          byte [] bytes = new byte[(int)entry.getSize()] // broken
          foo.read(bytes,0,bytes.length); // decompress the data
          out.putNextEntry(entry);
          out.write(bytes,0,bytes.length); // subsequenly recompress it.
          out.closeEntry();
        }
      }

      So, if you're selectively going from one zip to
      another you're constantly decompressing and
      recompressing data. To simplify this... The
      if statement above now becomes..

        if(keepEntry(entry))
          out.copyEntry(entry); // move it over

      Hope you approve.
      company - Park City Group , email - ###@###.###
      ======================================================================

            sherman Xueming Shen
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: