Here you can find the source of copyIterator(Iterable
public static <T> List<T> copyIterator(Iterable<T> iterable)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Main { public static <T> List<T> copyIterator(Iterable<T> iterable) { Iterator<T> iterator = iterable.iterator(); List<T> copy = new ArrayList<T>(); while (iterator.hasNext()) copy.add(iterator.next());//www . j ava 2 s.co m return copy; } }