Here you can find the source of listToString(String itemName, List list)
private static String listToString(String itemName, List list)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { private static String listToString(String itemName, List list) { StringBuffer buffer = new StringBuffer("\n\t< " + itemName + " >\n"); Iterator iterator = list.iterator(); for (; iterator.hasNext();) { buffer.append("\t\t< ").append(iterator.next().toString()).append(" >\n"); }//from w w w . j av a2s .c o m buffer.append("\t< " + itemName + " >"); return buffer.toString(); } }