I want something like this:
public void CopyIteratorIntoList(Iterator<Foo> fooIterator) {
List<Foo> fooList = new ArrayList<Foo>();
fooList.addAll(fooIterator);
}
which should be equivalent to:
public void CopyIteratorIntoList(Iterator<Foo> fooIterator) {
List<Foo> fooList = new ArrayList<Foo>();
while(fooIterator.hasNext())
fooList.add(fooIterator.next());
}
Is there any method in the API to achieve that, or is this the only way?