StreamUtils { public static <T> List<T> iteratorToList(Iterator<T> iterator) { return stream(spliteratorUnknownSize(iterator, ORDERED), false).collect(toCollection(ArrayList::new)); }  static Collector<T, List<T>, Optional<T>> singletonOptionalCollector(); static Collector<T, List<T>, T> singletonCollector(); static List<T> iteratorToList(Iterator<T> iterator);  }
@Test public void testIteratorToList() throws Exception { assertEquals("1", iteratorToList(asList("1").iterator()).get(0)); }