zoukankan      html  css  js  c++  java
  • StingUtils.isBlank与isNotBlank

    /**
         * <p>Checks if a CharSequence is empty (""), null or whitespace only.</p>
         *
         * <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p>
         *
         * <pre>
         * StringUtils.isBlank(null)      = true
         * StringUtils.isBlank("")        = true
         * StringUtils.isBlank(" ")       = true
         * StringUtils.isBlank("bob")     = false
         * StringUtils.isBlank("  bob  ") = false
         * </pre>
         *
         * @param cs  the CharSequence to check, may be null
         * @return {@code true} if the CharSequence is null, empty or whitespace only
         * @since 2.0
         * @since 3.0 Changed signature from isBlank(String) to isBlank(CharSequence)
         */
    public static boolean isBlank(final CharSequence cs) {
            int strLen;
            if (cs == null || (strLen = cs.length()) == 0) {
                return true;
            }
            for (int i = 0; i < strLen; i++) {
                if (!Character.isWhitespace(cs.charAt(i))) {
                    return false;
                }
            }
            return true;
        }
    
        /**
         * <p>Checks if a CharSequence is not empty (""), not null and not whitespace only.</p>
         *
         * <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p>
         *
         * <pre>
         * StringUtils.isNotBlank(null)      = false
         * StringUtils.isNotBlank("")        = false
         * StringUtils.isNotBlank(" ")       = false
         * StringUtils.isNotBlank("bob")     = true
         * StringUtils.isNotBlank("  bob  ") = true
         * </pre>
         *
         * @param cs  the CharSequence to check, may be null
         * @return {@code true} if the CharSequence is
         *  not empty and not null and not whitespace only
         * @since 2.0
         * @since 3.0 Changed signature from isNotBlank(String) to isNotBlank(CharSequence)
         */
        public static boolean isNotBlank(final CharSequence cs) {
            return !isBlank(cs);
        }
    
  • 相关阅读:
    7.9 C++ STL算法
    7.8 C++容器适配器
    7.7 C++基本关联式容器
    Django项目静态文件加载失败问题
    Centos6.5安装mysql5.7详解
    使用Xshell上传下载文件
    linux中MySQL本地可以连接,远程连接不上问题
    Linux常用命令
    Linux环境安装python3
    python 字符串最长公共前缀
  • 原文地址:https://www.cnblogs.com/DiZhang/p/12544886.html
Copyright © 2011-2022 走看看