<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
想使用这个工具类,要先在pom文件里引入依赖。
StringUtils.isEmpty("a"),输出为false
StringUtils.isEmpty(""),输出为true
StringUtils.isEmpty(" "),输出为false
StringUtils.isEmpty("\t"),输出为false
StringUtils.isEmpty(null),输出为true
--------------------------------------------------
StringUtils.isBlank("a"),输出为false
StringUtils.isBlank(""),输出为true
StringUtils.isBlank(" "),输出为true
StringUtils.isBlank("\t"),输出为true
StringUtils.isBlank(null),输出为true
代码实现对比,我认为isBlank是要比isEmpty好用的。