泛型到可迭代转换器 [英] generic Enumeration to Iterable converter

查看:163
本文介绍了泛型到可迭代转换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆