Here you can find the source of parseCsvString(String toParse)
Parameter | Description |
---|---|
toParse | String to parse |
public static List<String> parseCsvString(String toParse)
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { /**// w ww . j a va 2 s .com * Parse comma separated string into list of tokens. Tokens are trimmed, empty tokens are not in result. * * @param toParse String to parse * @return List of tokens if at least one token exists, null otherwise. */ public static List<String> parseCsvString(String toParse) { if (toParse == null || toParse.length() == 0) { return null; } String[] t = toParse.split(","); if (t.length == 0) { return null; } List<String> ret = new ArrayList<String>(); for (String s : t) { if (s != null) { s = s.trim(); if (s.length() > 0) { ret.add(s); } } } if (ret.isEmpty()) return null; else return ret; } /** * Check if String value is null or empty. * * @param src value * @return <code>true</code> if value is null or empty */ public static boolean isEmpty(String src) { return (src == null || src.length() == 0 || src.trim().length() == 0); } }