Ever have one of those objects that want to give you an iterator and don’t have a method for getting it as a list? Well created another new method for my ListUtils class. ListUtils::iteratre() it takes an iterator and converts it into a List for you.
/**
* Convert and Iterator of E to a List of E
* @param iterator Iterator of E to convert
* @param <E> Type to iterate over
* @return List of E converted.
*/
public static <E> List<E> iterate(Iterator<E> iterator) {
Iterable<E> iterable = () -> iterator;
return StreamSupport.stream(iterable.spliterator(), false).collect(Collectors.toList());
}