Here you can find the source of stringToArray(String str)
public static double[] stringToArray(String str)
//package com.java2s; //License from project: Open Source License import java.util.Locale; import java.util.Scanner; public class Main { public static double[] stringToArray(String str) { Scanner scn = new Scanner(str); scn.useLocale(Locale.ENGLISH); int length = 0; while (scn.hasNextDouble()) { length++;/*ww w. j av a 2s. c o m*/ scn.nextDouble(); } scn.close(); scn = new Scanner(str); scn.useLocale(Locale.ENGLISH); double[] array = new double[length]; for (int i = 0; i < length; i++) { array[i] = scn.nextDouble(); } return array; } }