Here you can find the source of listToString(List
static <T> String listToString(List<T> lines)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { static <T> String listToString(List<T> lines) { return listToString(lines, "\n"); }//from ww w. j a v a 2 s.co m static <T> String listToString(List<T> lines, String delim) { StringBuilder sb = new StringBuilder(); for (T l : lines) { if (sb.length() > 0) { sb.append(delim); } sb.append(l); } return sb.toString(); } }