StringUtils裡有一些比較常用的方法 

                StringUtils.isEmpty()判斷某字串是否為空值,為空值的標準是  字串等於null 或字串的長度為 0 的狀態下  
System.out.println(StringUtils.isEmpty(null));//true
System.out.println(StringUtils.isEmpty(""));//true
System.out.println(StringUtils.isEmpty(" "));//false
System.out.println(StringUtils.isEmpty("abc"));//false
System.out.println(StringUtils.isEmpty("   abc   "));//false
 
               StringUtils.isNotEmpty()而相反的就是不為空值不為空值的標準是字串不等於null 或字串的長度不為 0 的狀態下  
               System.out.println(StringUtils.isNotEmpty(null));// false
文章標籤

PG Levin Li 發表在 痞客邦 留言(0) 人氣()