common-lang

common-lang和beanutil

老子叫甜甜 提交于 2019-12-07 01:45:53
俗话说工欲善其事必先利其器,好的工具类可以节省我们额外早轮子的时间。 有时候为了优化性能,对字符串的处理尽量避免正则表达式的使用,可以考虑commons-lang,主要是针对string操作的工具类。 版本:commons-lang3-3.1.jar Apache Commons包估计是Java中使用最广发的工具包了,很多框架都依赖于这组工具包中的一部分,它提供了我们常用的一些编程需要,但是JDK没能提供的机能,最大化的减少重复代码的编写。 1、字符串的空判断 //isEmpty System.out.println(StringUtils.isEmpty(null)); // true System.out.println(StringUtils.isEmpty("")); // true System.out.println(StringUtils.isEmpty(" ")); // false System.out.println(StringUtils.isEmpty("bob")); // false System.out.println(StringUtils.isEmpty(" bob ")); // false //isBlank System.out.println(StringUtils.isBlank(null)); // true System.out