| <dependency> |
| <groupId>org.apache.commons</groupId> |
| <artifactId>commons-lang3</artifactId> |
| <version>3.9</version> |
| </dependency> |
| import org.apache.commons.lang3.StringUtils; |
| import org.junit.Test; |
| |
| public class StringUtilsTest { |
| |
| |
| |
| |
| |
| |
| @Test |
| public void test3() { |
| String str = "12345678911"; |
| |
| String left = StringUtils.left(str, 3); |
| String right = StringUtils.right(str, 4); |
| System.out.println(left+"****" + right); |
| |
| String padResult = StringUtils.rightPad(left, 7, '*'); |
| System.out.println(padResult + right); |
| } |
| |
| |
| |
| |
| @Test |
| public void test2() { |
| String str = " "; |
| System.out.println(StringUtils.isEmpty(str)); |
| |
| System.out.println(StringUtils.isNotEmpty(str)); |
| } |
| |
| |
| |
| |
| @Test |
| public void test1() { |
| String str = " "; |
| System.out.println(StringUtils.isBlank(str)); |
| |
| System.out.println(StringUtils.isNotBlank(str)); |
| } |
| |
| } |
| import org.apache.commons.lang3.math.NumberUtils; |
| import org.junit.Test; |
| |
| public class NumberUtilsTest { |
| |
| |
| |
| @Test |
| public void test1() { |
| String str ="12.3aaa"; |
| |
| System.out.println(str+"isDigits结果:"+NumberUtils.isDigits(str)); |
| |
| System.out.println(str+"isParsable结果:"+NumberUtils.isParsable(str)); |
| |
| System.out.println(str+"isCreatable结果:"+NumberUtils.isCreatable(str)); |
| str = "12.3"; |
| System.out.println(str+"isDigits结果:"+NumberUtils.isDigits(str)); |
| System.out.println(str+"isParsable结果:"+NumberUtils.isParsable(str)); |
| System.out.println(str+"isCreatable结果:"+NumberUtils.isCreatable(str)); |
| str ="+12.3"; |
| System.out.println(str+"isDigits结果:"+NumberUtils.isDigits(str)); |
| System.out.println(str+"isParsable结果:"+NumberUtils.isParsable(str)); |
| System.out.println(str+"isCreatable结果:"+NumberUtils.isCreatable(str)); |
| str ="12"; |
| System.out.println(str+"isDigits结果:"+NumberUtils.isDigits(str)); |
| System.out.println(str+"isParsable结果:"+NumberUtils.isParsable(str)); |
| System.out.println(str+"isCreatable结果:"+NumberUtils.isCreatable(str)); |
| str ="09"; |
| System.out.println(str+"isDigits结果:"+NumberUtils.isDigits(str)); |
| System.out.println(str+"isParsable结果:"+NumberUtils.isParsable(str)); |
| |
| System.out.println(str+"isCreatable结果:"+NumberUtils.isCreatable(str)); |
| } |
| } |
| import org.apache.commons.lang3.ObjectUtils; |
| import org.junit.Test; |
| |
| public class ObjectUtilsTest { |
| |
| |
| |
| |
| @Test |
| public void test2() { |
| |
| System.out.println(ObjectUtils.identityToString("abc")); |
| } |
| |
| |
| |
| @Test |
| public void test1() { |
| String str1=null; |
| String str2=null; |
| String str3="str233"; |
| System.out.println(ObjectUtils.firstNonNull(str1, str2, str3)); |
| } |
| } |
| import org.apache.commons.lang3.ArrayUtils; |
| import org.junit.Test; |
| |
| public class ArrayUtilsTest { |
| |
| |
| |
| @Test |
| public void test2(){ |
| int[] ints = new int[1]; |
| ints[0] = 3; |
| |
| System.out.println(ArrayUtils.toString(ints)); |
| |
| int[] newArr = ArrayUtils.add(ints, 7); |
| System.out.println(ArrayUtils.toString(ints)); |
| System.out.println(ArrayUtils.toString(newArr)); |
| |
| } |
| |
| |
| |
| @Test |
| public void test1(){ |
| Integer[] ints = new Integer[0]; |
| ints = null; |
| System.out.println(ArrayUtils.isEmpty(ints)); |
| } |
| } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 一文读懂知识蒸馏
· 终于写完轮子一部分:tcp代理 了,记录一下