Here you can find the source of stringToDoubleList(String s)
public static List<Double> stringToDoubleList(String s)
//package com.java2s; /*/* www. j a v a2 s. co m*/ * $Id$ * * Copyright 1998,1999,2000,2001 by Rockhopper Technologies, Inc., * 75 Trueman Ave., Haddonfield, New Jersey, 08033-2529, U.S.A. * All rights reserved. * * This software is the confidential and proprietary information * of Rockhopper Technologies, Inc. ("Confidential Information"). You * shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement * you entered into with RTI. */ import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static List<Double> stringToDoubleList(String s) { Scanner scanner = new Scanner(s); if (s.indexOf(',') != -1) { scanner.useDelimiter(","); } List<Double> data = new ArrayList<Double>(); while (scanner.hasNextDouble()) { data.add(scanner.nextDouble()); } scanner.close(); return data; } }