Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Main { public static <T> List<T> listFromIterator(Iterator<T> i) { List<T> retval = new ArrayList<T>(); while (i.hasNext()) retval.add(i.next()); return retval; } }