1. 程式人生 > >java 字符串判斷是否為空

java 字符串判斷是否為空

判斷 urn 創建 null ring return trim rep 日期

    /**
     * 方法描述:字符串判斷是否為空
     * 創建作者:李興武
     * 創建日期:2017-06-22 19:50:01
     *
     * @param str the str
     * @return the boolean
     */
    public static Boolean isBlank(String str){
        if(str!=null) str = str.replaceAll("\r\n|\n\r|\n|\r|\f|\t", "");
        if(str==null) return true;
        
else if(str.equals("")) return true; else if(str.equals("null")) return true; else if(str.equals("NULL")) return true; else if(str.equals("(null)")) return true; else if(str.equals("(NULL)")) return true; else if(str.trim().length()==0) return true; return
false; }

以下字符全部返回true
1. \r\n|\n\r|\n|\r|\f|\t
2. null
3. “”
4. “null”
5. “NULL”
6. “(null)”
7. “(NULL)”

java 字符串判斷是否為空