刚开始还自己写了个,
public static <T> String listToString(List<T> list) {
if(list != null && !list.isEmpty()){StringBuffer sb = new StringBuffer();
for (T t : list) {
sb.append(",").append(String.valueOf(t));
}
return sb.substring(1);
}
return null;
}
后来发现StringUtils里面就有这个方法
StringUtils.join(list,",");
就可以了!