Java Scanner Usage stringToDoubleList(String s)

Here you can find the source of stringToDoubleList(String s)

Description

string To Double List

License

Open Source License

Declaration

public static List<Double> stringToDoubleList(String s) 

Method Source Code

//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;
    }
}

Related

  1. removeNLinesForwardsFromStringMatch(String text, String match, int n)
  2. selectProject(List projectList)
  3. splitLines(String string)
  4. splitToDouble(String input)
  5. stringToArray(String str)
  6. swapElements(int length, int maxValue)
  7. termInput()
  8. Tokenize(String s, String s2, String s3)
  9. toNumeric(String ip)