将一个list转换成String org.springframework.util.StringUtils

将一个list转换成String org.springframework.util.StringUtils

public static String collectionToDelimitedString(Collection<?> coll, String delim, String prefix, String suffix) {
if (CollectionUtils.isEmpty(coll)) {
return "";
}
StringBuilder sb = new StringBuilder();
Iterator<?> it = coll.iterator();
while (it.hasNext()) {
sb.append(prefix).append(it.next()).append(suffix);
if (it.hasNext()) {
sb.append(delim);
}
}
return sb.toString();
}

猜你喜欢

转载自woshizhuzi.iteye.com/blog/2347982
今日推荐