Here you can find the source of buildString(Collection
public static String buildString(Collection<String> args, String seperator, int startingArg, int maxLength)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { public static String buildString(Collection<String> args, String seperator, int startingArg, int maxLength) { List<String> retList = new ArrayList<String>(); String ret = ""; for (int i = startingArg; i < args.size(); i++) { String s = (String) args.toArray()[i]; ret += s + seperator;//from w ww . j av a 2s . c o m if (ret.length() > maxLength) { retList.add(ret); ret = ""; } } retList.add(ret); ret = ""; for (String s : retList) { ret += s + "\n"; } if (ret.length() > 2) { ret = ret.substring(0, (ret.length() - seperator.length()) - 1); } return ret; } }