Java CSV String Split SplitCSV(String csv)

Here you can find the source of SplitCSV(String csv)

Description

Split CSV

License

Open Source License

Declaration

public static ArrayList<Integer> SplitCSV(String csv) throws Exception 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

public class Main {
    public static ArrayList<Integer> SplitCSV(String csv) throws Exception {
        ArrayList<Integer> list = new ArrayList<Integer>();

        // Return empty list if no entries
        csv = csv.trim();// w  w  w.j a v  a2 s  .  co m
        if (csv.length() == 0) {
            return list;
        }

        // Split our our array
        try {
            for (String s : csv.split(",")) {
                s = s.trim();
                list.add(Integer.parseInt(s));
            }
        } catch (Exception e) {
            throw new Exception("List must contain numbers.");
        }

        return list;
    }
}

Related

  1. csvToArray(String s)
  2. csvToTrimArray(CharSequence charsequence)
  3. getContentsFromNumpyCSVString( String numpyString)
  4. getCsvValues(String line)
  5. getValuesFromCSVString(String csvString)
  6. splitCSV(String inputString)
  7. splitCSV(String str)
  8. splitCSV(String str)
  9. splitCSV(String str)