Java examples for java.lang:String Join
list to String
//package com.java2s; import java.util.Iterator; import java.util.List; public class Main { public static void main(String[] argv) throws Exception { List list = java.util.Arrays.asList("asdf", "java2s.com"); System.out.println(listtoString(list)); }// w ww.j a v a 2 s .c o m public static String listtoString(List<String> list) { return listtoString(list, ",", "'"); } public static String listtoString(List<String> list, String split, String yh) { StringBuffer buf = new StringBuffer(); Iterator<String> iter = list.iterator(); boolean hasNext = iter.hasNext(); while (hasNext) { String o = iter.next(); buf.append(yh + String.valueOf(o) + yh); hasNext = iter.hasNext(); if (hasNext) buf.append(split); } return buf.toString(); } }