code: public static <T> List<T> asList(final Iterator<T> iterator)
     {
        List<T> result = new ArrayList<T>();
        while (iterator.hasNext())
        {
           T t = iterator.next();
           result.add(t);
        }
        return result;
     }
docs: Return the elements of the given {@link Iterator} as a {@link List}.