android/guava/src/com/google/common/collect/Iterators.java
@GwtIncompatible // Array.newInstance(Class, int)
  public static <T> T[] toArray(Iterator<? extends T> iterator, Class<T> type) {
    List<T> list = Lists.newArrayList(iterator);
    return Iterables.toArray(list, type);
  }
@GwtIncompatible // Array.newInstance(Class, int)
  public static <T> T[] toArray(Iterator<? extends T> iterator, Class<T> type) {
    List<T> list = Lists.newArrayList(iterator);
    return Iterables.toArray(list, type);
  }
Copies an iterator's elements into an array. The iterator will be left exhausted: its {@code
hasNext()} method will return {@code false}.

@param iterator the iterator to copy
@param type the type of the elements
@return a newly-allocated array into which all the elements of the iterator have been copied