http://commons.apache.org/proper/commons-lang/javadocs/api-3.9/
<dependency>
<groupId>org.apache.commonsgroupId>
<artifactId>commons-lang3artifactId>
<version>3.9version>
dependency>
StringUtils.isNotEmpty(xxxx)
StringUtils.trim(xxxx)
StringUtils.deleteWhitespace(xxxx)
StringUtils.removeStart("www.foxwho.com","www.foxwho")
StringUtils.strip(xxxx)
StringUtils.equals(null, null)
忽略大小写
StringUtils.equalsIgnoreCase(null, null)
StringUtils.indexOf("XX", "X")
StringUtils.contains("XX", "X")
StringUtils.startsWithAny(null, null);// false
StringUtils.startsWithAny(null, new String[] { "abc" });// false
StringUtils.startsWithAny("abcxyz", null);// false
StringUtils.startsWithAny("abcxyz", new String[] { "" });// true
StringUtils.startsWithAny("abcxyz", new String[] { "abc" });// true
StringUtils.startsWithAny("abcxyz", new String[] { null, "xyz", "abc" });// true
StringUtils.startsWithAny("abcxyz", null, "xyz", "ABCX");// false
StringUtils.startsWithAny("ABCXYZ", null, "xyz", "abc");// false
StringUtils.substring("XX", "X")
StringUtils.split("XX=X")
StringUtils.join(["XX", "X"])
右补齐
StringUtils.rightPad("23",5,"0");
结果
23000
左补齐
StringUtils.leftPad("23",5,"0");
结果
00023
中部补齐
StringUtils.center(String str,int size,String padStr);
StringUtils.capitalize()
反向大写 StringUtils.swapCase
StringUtils.isAlpha
StringUtils.reverse
StringUtils.abbreviate
StringUtils.wrap
import org.apache.commons.lang3.ArrayUtils;
String[] arr=new String[]{"aaa","bbbb","cccc"}
String value="cccc";
ArrayUtils.contains(arr,value);
不要使用 arrays.aslist(arr).contains(value)
部分来源:
https://blog.csdn.net/qq_39964694/article/details/80334556