commons-text StrBuilder字符串构建工具类例子

时间:2023-03-08 17:48:21
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, ","));
} }

运行结果:

commons-text StrBuilder字符串构建工具类例子

使用场景:可以再拼接sql条件时使用。