JDK-6259669 : RFE: java.util.jar.ZipFile should provide "Enumeration getEntries(Pattern p)"
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 6
  • Priority: P4
  • Status: Resolved
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2005-04-21
  • Updated: 2015-11-11
  • Resolved: 2015-11-11
Related Reports
Relates :  
Description
If I want to search a class name starts with a certain string, the only option I have now is to enumerate all the entries in the jar file and match myself. It is not efficient doing that. It would be very helpful if we could provide a way to scan the jar file for classes I don't know exact name but having a pattern. 

See bug 4908648's evaluation for more details. Actually when the user calls Locale.getAvailableLocales to get all the supported locales in JRE, the Locale code will scan all the jar files in class path to look for class starts with sun.text.resource.LocaleElements_* and get "*" to see what the locale of that resource file associated with. In this case, we don't know exact name of the class, but we know the entry name for those classes starts with a certain pattern.

###@###.### 2005-04-21 20:59:15 GMT

Comments
We now have ZipFile.stream().filter(...) to filter out/in the entries needed.
11-11-2015

EVALUATION Enumerations are denigrated; we're supposed to be using Iterator now. This sort of thing is certainly a reasonable request. Currently the only way to access a zip file is via the exact name, or by linear search. Other reasonable requests are for hierarchical search. We have a precedent in the use of filename filters in java.io. Note, however, that if implemented in pure Java, this would not buy you much performance. ###@###.### 2005-04-21 22:38:36 GMT
21-04-2005