List of utility methods to do Comma Separated List
String | toCommaDelimited(List Returns the comma-delimited String containing the specified values. StringBuilder buffer = new StringBuilder(); for (String value : values) { if (buffer.length() > 0) { buffer.append(","); buffer.append(value); return buffer.toString(); ... |
String | toCommaList(Collection> items) to Comma List if (items == null || items.size() == 0) return (null); String itemList = ""; Iterator<?> it = items.iterator(); while (it.hasNext()) { String item = it.next().toString(); itemList += item + ","; itemList = itemList.substring(0, itemList.length() - 1); return (itemList); |
String | toCommaSeparated(List to Comma Separated if (list != null) { StringBuffer buff = new StringBuffer(); boolean comma = false; for (String item : list) { if (comma) { buff.append(','); comma = true; ... |
String | toCommaSeparated(List to Comma Separated StringBuilder sb = new StringBuilder(); for (String property : list) { sb.append(property).append(","); sb.deleteCharAt(sb.length() - 1); return sb.toString(); |
String | toCommaSeparatedString(List to Comma Separated String return toString(list, ", "); |
List | toList(final String commaSeparatedString) to List List<String> list = new ArrayList<>(); if (commaSeparatedString == null || commaSeparatedString.trim().length() == 0) { return list; String[] values = commaSeparatedString.split(","); for (String value : values) { list.add(value.trim()); return list; |
List | toListDelimitedByComma(String s) Turn a long string into a list split by our delimeter if (s == null) return Collections.EMPTY_LIST; List results = new ArrayList(); String[] terms = s.split(DELIMETER); for (int i = 0; i < terms.length; i++) { String term = terms[i].trim(); if (term.length() > 0) { results.add(term); ... |
List | toListOfNonEmptyStringsDelimitedByCommaOrSemicolon(String s) to List Of Non Empty Strings Delimited By Comma Or Semicolon if (s == null) return Collections.EMPTY_LIST; List results = new ArrayList(); String[] terms = s.split(SEPARATOR); for (int i = 0; i < terms.length; i++) { String term = terms[i].trim(); if (term.length() > 0) { results.add(term); ... |
List | toListOfStringsDelimitedByCommaOrSemicolon(String s) This version returns the complete list, including empty string, if such entry is empty if (s == null) { return Collections.EMPTY_LIST; List results = new ArrayList(); String[] terms = s.split(SEPARATOR); for (int i = 0; i < terms.length; i++) { String term = terms[i].trim(); results.add(term); ... |