锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
銆銆鍒ゆ柇鏌愬瓧絎︿覆鏄惁涓虹┖錛屼負絀虹殑鏍囧噯鏄?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
銆銆2. public static boolean isNotEmpty(String str)
銆銆鍒ゆ柇鏌愬瓧絎︿覆鏄惁闈炵┖錛岀瓑浜?!isEmpty(String str)
銆銆涓嬮潰鏄ず渚嬶細
銆銆StringUtils.isNotEmpty(null) = false
銆銆StringUtils.isNotEmpty("") = false
銆銆StringUtils.isNotEmpty(" ") = true
銆銆StringUtils.isNotEmpty(" ") = true
銆銆StringUtils.isNotEmpty("bob") = true
銆銆StringUtils.isNotEmpty(" bob ") = true
銆銆3. public static boolean isBlank(String str)
銆銆鍒ゆ柇鏌愬瓧絎︿覆鏄惁涓虹┖鎴栭暱搴︿負0鎴栫敱絀虹櫧絎?whitespace) 鏋勬垚
銆銆涓嬮潰鏄ず渚嬶細
銆銆StringUtils.isBlank(null) = true
銆銆StringUtils.isBlank("") = true
銆銆StringUtils.isBlank(" ") = true
銆銆StringUtils.isBlank(" ") = true
銆銆StringUtils.isBlank("\t \n \f \r") = true //瀵逛簬鍒惰〃絎︺佹崲琛岀銆佹崲欏電鍜屽洖杞︾
銆銆StringUtils.isBlank() //鍧囪瘑涓虹┖鐧界
銆銆StringUtils.isBlank("\b") = false //"\b"涓哄崟璇嶈竟鐣岀
銆銆StringUtils.isBlank("bob") = false
銆銆StringUtils.isBlank(" bob ") = false
銆銆4. public static boolean isNotBlank(String str)
銆銆鍒ゆ柇鏌愬瓧絎︿覆鏄惁涓嶄負絀轟笖闀垮害涓嶄負0涓斾笉鐢辯┖鐧界(whitespace) 鏋勬垚錛岀瓑浜?!isBlank(String str)
銆銆涓嬮潰鏄ず渚嬶細
銆銆StringUtils.isNotBlank(null) = false
銆銆StringUtils.isNotBlank("") = false
銆銆StringUtils.isNotBlank(" ") = false
銆銆StringUtils.isNotBlank(" ") = false
銆銆StringUtils.isNotBlank("\t \n \f \r") = false
銆銆StringUtils.isNotBlank("\b") = true
銆銆StringUtils.isNotBlank("bob") = true
銆銆StringUtils.isNotBlank(" bob ") = true