前言:

1,StringUtils.isNotEmpty(str)和StringUtils.isNotBlank(str)都是用来做非空判断的

2,通常用isNotBlank

3,import org.apache.commons.lang.StringUtils;

正文:

1,主要差别:isNotBlank多了去除字符串前后空格再做判断

isNotEmpty(str) 等价于 str != null && str.length > 0
isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length > 0
同理
isEmpty 等价于 str == null || str.length == 0
isBlank 等价于 str == null || str.length == 0 || str.trim().length == 0

2,StringUtils需要的jar包

pom.xml

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>

参考博客:

1,StringUtils中 isNotEmpty 和isNotBlank的区别【java字符串判空】 - 涤新云 - 博客园

https://www.cnblogs.com/dixinyunpan/p/6088612.html

【Java】【8】StringUtils中isNotEmpty和isNotBlank的区别的更多相关文章

  1. StringUtils中 isNotEmpty 和isNotBlank的区别【java字符串判空】

    isNotEmpty(str)等价于 str != null && str.length > 0 isNotBlank(str) 等价于 str != null &&am ...

  2. 【转】 StringUtils中 isNotEmpty 和isNotBlank的区别

    [转自]http://blog.csdn.net/foamflower/article/details/5713604 isNotEmpty将空格也作为参数,isNotBlank则排除空格参数 Str ...

  3. StringUtils中 isNotEmpty 和isNotBlank的区别

    isNotEmpty : 判断某字符串是否非空 StringUtils.isNotEmpty(null) = false StringUtils.isNotEmpty("") = ...

  4. Java正则表达中Greedy Reluctant Possessive 的区别

    Java正则表达中Greedy Reluctant Possessive 的区别 分类: java2015-01-16 00:28 1280人阅读 评论(9) 收藏 举报 正则表达式Java   目录 ...

  5. java中StringUtils中isEmpty 和isBlank的区别

    StringUtils在commons-lang-2.2.jar包中:org.apache.commons.lang.StringUtils ; StringUtils方法的操作对象是java.lan ...

  6. StringUtils的isNotEmpty和isNotBlank

    StringUtils中一共有130多个方法,并且都是static的,所以我们可以这样调用StringUtils.xxx():今天笔者记录下常用的isNotEmpty和isNotBlank:这两个都是 ...

  7. StringUtils中isEmpty 和isBlank的区别

    StringUtils在commons-lang-2.2.jar包中:org.apache.commons.lang.StringUtils ; StringUtils方法的操作对象是java.lan ...

  8. StringUtils中 isEmpty 和isBlank的区别

    StringUtils方法的操作对象是java.lang.String类型的对象,是JDK提供的String类型操作方法的补充,并且是null安全的(即如果输入参数String为null则不会抛出Nu ...

  9. org.apache.commons.lang.StringUtils中isEmpty和isBlank的区别

    public static boolean isEmpty(String str) 判断某字符串是否为空,为空的标准是str==null或str.length()==0 StringUtils.isE ...

随机推荐

  1. 论文笔记之:Learning Cross-Modal Deep Representations for Robust Pedestrian Detection

    Learning Cross-Modal Deep Representations for Robust Pedestrian Detection 2017-04-11  19:40:22  Moti ...

  2. Latex: "Missing $ inserted" 解决方法

    参考: Latex报"Missing $ inserted"的解决方法 Latex: "Missing $ inserted" 解决方法 原因一:在文中出现&q ...

  3. Ubuntu下codeblocks不能自动缩进的问题

    如果在codeblocks中设置了自动缩进但是没有效果的话,在终端中执行sudo apt-get install codeblocks-contrib命令.

  4. 51nod 1437 迈克步(单调栈)

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1437 题意: 思路: 单调栈题.求出以每个数为区间最大值的区间范围即可. ...

  5. Java LocalDateTime,DateTimeFomatter----JDK8新时间类的简单使用

    JDK8中增加了一系列时间的类, (据说)是为了干掉过去的Date,Calendar类的, 过去的Date类(据说)有着线程不安全等诸多弊端, 至于我的个人感受就是用起来实在是很麻烦,我一般封装成几个 ...

  6. PL/SQL Developer登录出现——Using a filter for all users can lead to poor performance!

    用PL/SQL  Developer登录Oracle时提示:Using a filter for all users can lead to poor performance! 分析:与Oracle的 ...

  7. UnicodeEncodeError: 'gbk' codec can't encode character '\u25aa' in position 15: illegal multibyte sequence

    UnicodeEncodeError: 'gbk' codec can't encode character '\u25aa' in position 15: illegal multibyte se ...

  8. JavaScript 局部刷新

    JavaScript局部刷新具体代码展示如下 1.  #tabList代表需要刷新的元素的对象 2.  第二个#tabList 如果后面有第三个元素,那么后面需要加>*符号,如果不加,容易造成C ...

  9. windows与linux换行符

    我一次linux上写的脚本,利用vim进行脚本编写,然后下载下来在nodepad++上面打开,在nodepad上面新建了一个文件将原来文件内容复制过去,保存后下载复制文件在linux上面进行运行,发现 ...

  10. MySQL字段拼接Concat

    有时候,从数据库中拿出的数据并不是我们想要的格式,比如,有以下的vendors表 如果,想以 name (location)的格式展现出来,那么就要用到MySQL的Concat了. Concat()拼 ...