Here you can find the source of joinList(List list, String separator)
@SuppressWarnings("rawtypes") public static String joinList(List list, String separator)
//package com.java2s; /**/*w w w . ja va2 s . c o m*/ * Converts a line of text into an array of lower case words using a * BreakIterator.wordInstance(). <p> * * This method is under the Jive Open Source Software License and was * written by Mark Imbriaco. * * @param text a String of text to convert into an array of words * @return text broken up into an array of words. */ import java.util.List; import java.util.Iterator; public class Main { @SuppressWarnings("rawtypes") public static String joinList(List list, String separator) { String rtVal = ""; if (separator == null) separator = ","; Iterator it = list.iterator(); while (it.hasNext()) { rtVal += (String) it.next() + separator; } if (rtVal.length() > 1) return rtVal.substring(0, rtVal.length() - 1); else return rtVal; } @SuppressWarnings("rawtypes") public static String joinList(List list) { return joinList(list, null); } public static String substring(String str, int len) { len = len * 2; StringBuffer sb = new StringBuffer(); int counter = 0; for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c < 255) { counter++; } else { counter = counter + 2; } if (counter > len) { break; } sb.append(c); } return sb.toString(); } }