package com.skylink.junge.demo; import java.util.ArrayList;
import java.util.List; import org.apache.commons.text.StrBuilder; public class StrBuilderTest { public static void main(String[] args) {
String[] strs = new String[]{"111", "222", "333"};
StrBuilder strBuilder = new StrBuilder();
System.out.println(strBuilder.appendWithSeparators(strs, ",")); List<String> strList = new ArrayList<String>(3);
strList.add("444");
strList.add("555");
strList.add("666"); strBuilder.clear();
System.out.println(strBuilder.appendWithSeparators(strList, ","));
} }
运行结果:
使用场景:可以再拼接sql条件时使用。