rg.apache.commons.lang.StringUtils中的join方法可以将数组转化为字符串
Set转字符串,先将Set转数组,然后数组转字符串
@Test public void run5() { Set<String> set = new HashSet<String>(); set.add("lingq"); set.add("dengp"); set.add("liuw1"); System.out.println(set); Object[] array = set.toArray(); String splitSet = StringUtils.join(array); System.out.println("splitSet:" + splitSet); String splitSetWithComma = StringUtils.join(array, ","); System.out.println("splitSetWithComma:" + splitSetWithComma); }