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

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Won't Fix
    • Priority: P5
    • None
    • Affects Version/s: 6
    • Component/s: 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());
      }

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: