Here you can find the source of listToString(List
public static String listToString(List<String> segs, String splitter)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static String listToString(List<String> segs, String splitter) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < segs.size() - 1; i++) { sb.append(segs.get(i));/* w w w.j a v a2 s. com*/ sb.append(splitter); } sb.append(segs.get(segs.size() - 1)); return sb.toString(); } }