Here you can find the source of parseCSV(String csv)
Parameter | Description |
---|---|
csv | the string |
public static List<String> parseCSV(String csv)
//package com.java2s; /**//from w w w .jav a 2s .co m * Copyright 2011 Rowan Seymour * * This file is part of Kumva. * * Kumva is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Kumva is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Kumva. If not, see <http://www.gnu.org/licenses/>. */ import java.util.ArrayList; import java.util.List; public class Main { /** * Parses a CSV string into a list of strings, removing spaces and empty strings * @param csv the string * @return the list of strings */ public static List<String> parseCSV(String csv) { String[] vals = csv.split(","); List<String> strs = new ArrayList<String>(); for (String val : vals) { String v = val.trim(); if (v.length() > 0) strs.add(v); } return strs; } }