Here you can find the source of fillCollection(final Iterator
public static <T> void fillCollection(final Iterator<T> iterator, final Collection<T> collection)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.Iterator; public class Main { public static <T> void fillCollection(final Iterator<T> iterator, final Collection<T> collection) { while (iterator.hasNext()) { collection.add(iterator.next()); }//from www . ja va 2 s .c om } }