• StringUtils的isBlank与isEmply


     1 1. public static boolean isEmpty(String str) 
     2  
     3   判断某字符串是否为空,为空的标准是 str==null 或 str.length()==0
     4  
     5   下面是 StringUtils 判断是否为空的示例: 
     6  
     7   StringUtils.isEmpty(null) = true
     8  
     9   StringUtils.isEmpty("") = true
    10  
    11   StringUtils.isEmpty(" ") = false //注意在 StringUtils 中空格作非空处理 
    12  
    13   StringUtils.isEmpty("   ") = false
    14  
    15   StringUtils.isEmpty("bob") = false
    16  
    17   StringUtils.isEmpty(" bob ") = false
    18  
    19   2. public static boolean isNotEmpty(String str) 
    20  
    21   判断某字符串是否非空,等于 !isEmpty(String str) 
    22  
    23   下面是示例: 
    24  
    25   StringUtils.isNotEmpty(null) = false
    26  
    27   StringUtils.isNotEmpty("") = false
    28  
    29   StringUtils.isNotEmpty(" ") = true
    30  
    31   StringUtils.isNotEmpty("         ") = true
    32  
    33   StringUtils.isNotEmpty("bob") = true
    34  
    35   StringUtils.isNotEmpty(" bob ") = true
    36  
    37   3. public static boolean isBlank(String str) 
    38  
    39   判断某字符串是否为空或长度为0或由空白符(whitespace) 构成 
    40  
    41   下面是示例: 
    42  
    43   StringUtils.isBlank(null) = true
    44  
    45   StringUtils.isBlank("") = true
    46  
    47   StringUtils.isBlank(" ") = true
    48  
    49   StringUtils.isBlank("        ") = true
    50  
    51   StringUtils.isBlank("\t \n \f \r") = true   //对于制表符、换行符、换页符和回车符 
    52  
    53   StringUtils.isBlank()   //均识为空白符 
    54  
    55   StringUtils.isBlank("\b") = false   //"\b"为单词边界符 
    56  
    57   StringUtils.isBlank("bob") = false
    58  
    59   StringUtils.isBlank(" bob ") = false
    60  
    61   4. public static boolean isNotBlank(String str) 
    62  
    63   判断某字符串是否不为空且长度不为0且不由空白符(whitespace) 构成,等于 !isBlank(String str) 
    64  
    65   下面是示例: 
    66  
    67   StringUtils.isNotBlank(null) = false
    68  
    69   StringUtils.isNotBlank("") = false
    70  
    71   StringUtils.isNotBlank(" ") = false
    72  
    73   StringUtils.isNotBlank("         ") = false
    74  
    75   StringUtils.isNotBlank("\t \n \f \r") = false
    76  
    77   StringUtils.isNotBlank("\b") = true
    78  
    79   StringUtils.isNotBlank("bob") = true
    80  
    81   StringUtils.isNotBlank(" bob ") = true

    转自http://www.cnblogs.com/XiaoGer/

  • 相关阅读:
    CF538H Summer Dichotomy
    CF1558F Strange Sort
    CF429E Points and Segments
    CF986F Oppa Funcan Style Remastered
    [JOI Open 2016] 摩天大楼
    [做题笔记] 浅谈笛卡尔树结构的应用
    CF1383C String Transformation 2
    CF1558E Down Below
    weex打包安卓艰苦之路
    IntelliJ IDEA 推荐15款插件
  • 原文地址:https://www.cnblogs.com/cloudwind/p/2749254.html
Copyright © 2020-2023  润新知