Here you can find the source of convertToArray(Iterator
public static double[] convertToArray(Iterator<Double> iter)
//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 double[] convertToArray(Iterator<Double> iter) { return listToArray(convertToList(iter)); }/* w w w. j a va 2 s. c o m*/ private static double[] listToArray(List<Double> list) { double[] arr = new double[list.size()]; for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i); return arr; } public static List<Double> convertToList(Iterator<Double> iter) { List<Double> list = new ArrayList<Double>(); while (iter.hasNext()) list.add(iter.next()); return list; } }