Here you can find the source of createDelimitedString(String rawListAsString)
public static String createDelimitedString(String rawListAsString)
//package com.java2s; //License from project: Open Source License import java.util.List; import java.util.Arrays; public class Main { private static final String DEFAULT_DELIMITER = " "; private static final String REGEX_TO_SPLIT = "[\\s]+"; public static String createDelimitedString(String rawListAsString) { return createDelimitedString(rawListAsString, null); }/*w ww .j a va 2 s . c om*/ public static String createDelimitedString(String rawListAsString, String delimiter) { if (rawListAsString == null) return null; String[] argList = rawListAsString.trim().split(REGEX_TO_SPLIT); List<String> list = Arrays.asList(argList); return createDelimitedString(list, delimiter); } public static String createDelimitedString(List<String> list) { return createDelimitedString(list, null); } public static String createDelimitedString(List<String> list, String delimiter) { if (delimiter == null) delimiter = DEFAULT_DELIMITER; if (list == null) return null; /* todo: maybe replace with StringUtils later */ StringBuffer buffer = new StringBuffer(); for (String item : list) { buffer.append(item.trim()); if (list.indexOf(item) < list.size() - 1) { buffer.append(delimiter); } } return buffer.toString().trim(); } }