Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

generic Enumeration to Iterable converter [closed]

HttpServletRequest is using a lot of java.util.Enumeration. I would like to use them in for-each, so i need to convert them into interable. this is not a problem, but I since I have more than one project needing this I need a library to do this. I would rather not make my own - is there any standard library that supports this kind of decoration?

Is there a built-in construct to convert an Enumeration to an Iterable?

like image 496
IAdapter Avatar asked Nov 19 '11 22:11

IAdapter


People also ask

Is Enum an Iterable?

Enumeration is like an Iterator , not an Iterable .


1 Answers

java.util.Collections has a list method that copies an Enumeration into a List, which you can then use in a for-each loop (see javadoc).

like image 153
skaffman Avatar answered Sep 30 '22 00:09

skaffman