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

Have java.util.zip.ZipFile implement Iterable<ZipEntry>

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P5 P5
    • None
    • 6
    • core-libs

      A DESCRIPTION OF THE REQUEST :
      Since the request for a unification of enhanced for loops was turned down (see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6349852), I suggest the following:

      Make java.util.zip.ZipFile implement java.lang.Iterable<ZipEntry>.



      JUSTIFICATION :
      Make it easier and more consistent with other collection-type objects to iterate over the zip entries.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      ZipFile zipFile = new ZipFile("test.zip");
      for(ZipEntry entry : zipFile) {
        System.out.println(entry.getName());
      }

      ACTUAL -
      ZipFile zipFile = new ZipFile("test.zip");
      for(Enumeration<? extends ZipEntry> entries = zipFile.entries(); entries.hasMoreElements();) {
        ZipEntry entry = entries.nextElement();
        System.out.println(entry.getName());
      }

            sherman Xueming Shen
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: