泛型到可迭代转换器 [英] generic Enumeration to Iterable converter
问题描述
HttpServletRequest使用了大量的java.util.Enumeration。我想使用它们在for-each,所以我需要将它们转换为interable。这不是一个问题,但我自从我有一个以上的项目需要这个我需要一个库来做到这一点。
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?
可能是google / commons收藏中的东西吗?
maybe something in google/commons collections?
推荐答案
java.util.Collections
有一个列表
方法将枚举
复制到列表
中,然后可以在for-each循环中使用 javadoc )。
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).
这篇关于泛型到可迭代转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!