Here you can find the source of listToText(List
public static String listToText(List<String> list, String join)
//package com.java2s; /*/*from w ww . ja va 2 s .c o m*/ * Copyright (c) 2013, 2014 Chris Newland. * Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD * Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki */ import java.util.List; public class Main { public static String listToText(List<String> list, String join) { StringBuilder builder = new StringBuilder(); for (String line : list) { builder.append(line).append(join); } if (builder.length() > 0) { builder.deleteCharAt(builder.length() - 1); } return builder.toString(); } }