StringUtils 几个判断空值的方法
org.apache.commons.lang 包下,包含多个判断空或者空字符串的方法,下面看下原形
isEmpty方法原形:
public static boolean isEmpty(String str) {
    return ((str == null) || (str.length() == 0));
}
isNotEmpty 方法原形
public static boolean isNotEmpty(String str) {
    return ((str != null) && (str.length() > 0));
}
isBlank方法原形
public static boolean isBlank(String str) {
    int strLen;
    if ((str == null) || ((strLen = str.length()) == 0))
        return true;
    int strLen;
    for (int i = 0; i < strLen; ++i) {
        if (!(Character.isWhitespace(str.charAt(i)))) {
            return false;
        }
    }
    return true;
}
isNotBlank方法原形
public static boolean isNotBlank(String str) {
    int strLen;
    if ((str == null) || ((strLen = str.length()) == 0))
        return false;
    int strLen;
    for (int i = 0; i < strLen; ++i) {
        if (!(Character.isWhitespace(str.charAt(i)))) {
            return true;
        }
     }
     return false;
}
推荐使用isNotEmpty
本文来自:StringUtils 几个判断空值的方法-小码农,转载请保留本条链接,感谢!
                                    
                                    温馨提示:
                                
                                
                                    本文最后更新于 2021年01月26日,已超过 1,742 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我。
                                
                            正文到此结束
                    
                    
                - 本文标签: stringutils
 - 本文链接: https://djc8.cn/archives/method-for-stringutils-to-determine-null-values.html
 - 版权声明: 本文由小码农原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权
 
热门推荐
                        该篇文章的评论功能已被站长关闭
                    
        
                                    
                                    