Here you can find the source of listToString(List
public static String listToString(List<String> params, String sepator)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static String listToString(List<String> params, String sepator) { if (params.size() > 0) { StringBuffer buffer = new StringBuffer(); for (String string : params) { buffer.append(string + sepator); }//from w w w. j a va2 s. c o m String result = buffer.toString(); return result.substring(0, result.length() - 1); } else { return ""; } } public static String listToString(List<String> strings) { StringBuffer buffer = new StringBuffer(); if (strings != null) { for (String string : strings) { buffer.append("\"" + string + "\","); } return buffer.toString().substring(0, buffer.toString().length() - 1); } return buffer.append(" ").toString(); } public static String subString(String src, int length) { if (src == null) { return null; } int i = src.length(); if (i > length) { return src.substring(0, length); } return src; } }