hutool超级好用的Java工具类

导入依赖

<dependency>
    <groupId>cn.hutool</groupId>
    <artifactId>hutool-all</artifactId>
    <version>5.0.7</version>
</dependency>

StrUtil类,对字符串进行处理的工具类。

hasBlank、hasEmpty方法都是用来判断字符串是否为空的

@Test
//判断字符串是否为空
public void hasBlankOrhasEmptyTest(){
    
    
    String str1 = "  ";
    String str2 = "";
    System.out.println(StrUtil.hasBlank(str1));
    System.out.println(StrUtil.hasBlank(str2));
    System.out.println(StrUtil.hasEmpty(str1));
    System.out.println(StrUtil.hasEmpty(str2));
}

结果

true
true
false
true

猜你喜欢

转载自blog.csdn.net/weixin_45528650/article/details/109358602