code: public static <T> List<T> collect(Iterator<T> iterator) {
          List<T> list = new ArrayList<T>();
          while (iterator.hasNext()) {
              list.add(iterator.next());
          }
          return list;
      }
docs: Collect an iterator's elements into a List.
  
  @param iterator the iterator
  @param <T>      the element type
  @return a List containing the elements
  @since 1.9.3