Java中的字符串isNullOrEmpty? [英] String isNullOrEmpty in Java?

查看:4578
本文介绍了Java中的字符串isNullOrEmpty?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前肯定已经提出过,但 谷歌搜索没有找到它 。在任何标准的java库(包括apache / google / ...)中,是否存在字符串的静态 isNullOrEmpty()方法

This surely has been asked before, but Googling doesn't find it. Is there, in any of the standard java libraries (including apache/google/...), a static isNullOrEmpty() method for Strings?

推荐答案


  • StringUtils。 isEmpty(str) StringUtils.isNotEmpty(str)

  • StringUtils.isBlank(str) 来自Apache的 StringUtils.isNotBlank(str)

    • StringUtils.isEmpty(str) or StringUtils.isNotEmpty(str)
    • StringUtils.isBlank(str) or StringUtils.isNotBlank(str)
    • commons-lang

      空白是:一个由空格组成的字符串只有空白但不是

      The difference between empty and blank is : a string consisted of whitespaces only is blank but isn't empty.

      我通常更喜欢使用apache-commons,如果可能的话,而不是编写我自己的实用程序方法虽然对于像这样的简单方法也是合理的。

      I generally prefer using apache-commons if possible, instead of writing my own utility methods, although that is also plausible for simple ones like these.

      这篇关于Java中的字符串isNullOrEmpty?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆