Here you can find the source of splitCommaStr(String commaStr)
Parameter | Description |
---|---|
commaStr | a parameter |
public static List<String> splitCommaStr(String commaStr)
//package com.java2s; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; public class Main { /**/*from w ww .ja va 2 s. com*/ * Given a comma-delimited string, split it into an array of * strings, removing unneccessary whitespace. Also will remove * empty values (i.e. only whitespace). * * @param commaStr * @return an array of the strings, with leading and trailing * whitespace removed. */ public static List<String> splitCommaStr(String commaStr) { List<String> results = new ArrayList<String>(Arrays.asList(commaStr.trim().split("\\s*,\\s*"))); for (Iterator<String> it = results.iterator(); it.hasNext();) { String next = it.next(); next = next.trim(); if (next.equals("")) { it.remove(); } } return results; } }