zoukankan      html  css  js  c++  java
  • StringUtils.isEmpty和StringUtils.isBlank用法

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

        StringUtils.isEmpty(null) = true
        StringUtils.isEmpty("") = true 
        StringUtils.isEmpty(" ") = false //注意在 StringUtils 中空格作非空处理
        StringUtils.isEmpty("   ") = false
        StringUtils.isEmpty("bob") = false
        StringUtils.isEmpty(" bob ") = false

     public static boolean isBlank(String str) 
       判断某字符串是否为空或长度为0或由空白符(whitespace) 构成
       下面是示例:
          StringUtils.isBlank(null) = true
          StringUtils.isBlank("") = true
          StringUtils.isBlank(" ") = true
          StringUtils.isBlank("        ") = true
          StringUtils.isBlank(" f ") = true   //对于制表符、换行符、换页符和回车符

          StringUtils.isBlank()   //均识为空白符
          StringUtils.isBlank("") = false   //""为单词边界符
          StringUtils.isBlank("bob") = false
          StringUtils.isBlank(" bob ") = false

    转载于:https://www.cnblogs.com/zhaoleigege/p/7812933.html

  • 相关阅读:
    Oracle to_char格式化函数
    电脑快捷键大全
    Failed to create the Java Virtual Machine (Myeclipse或者eclipse启动报错)
    Java 面试题
    UVA1108 Mining Your Own Business
    无向图的连通性
    [NOI Online #2 提高组]子序列问题
    [NOI Online #3 提高组]优秀子序列
    POJ2430 Lazy Cows
    UVA1633 Dyslexic Gollum
  • 原文地址:https://www.cnblogs.com/twodog/p/12138876.html
Copyright © 2011-2022 走看看