Here you can find the source of trimAndJoin(List
public static String trimAndJoin(List<Object> values, String delimiter)
//package com.java2s; import java.util.*; public class Main { public static String trimAndJoin(List<Object> values, String delimiter) { if (values == null || values.isEmpty()) return null; StringBuilder delimited = new StringBuilder(); Iterator<Object> valuesI = values.iterator(); while (valuesI.hasNext()) { delimited.append(valuesI.next().toString().trim()); if (valuesI.hasNext()) delimited.append(delimiter); }/*from w ww . j av a 2 s . co m*/ return delimited.toString(); } }