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);
        }
    
  • 相关阅读:
    C# 基本数据类型
    java二进制,原码、反码、补码、位运算
    .net邮件发送[c#]
    linux软件安装命令
    VB.net实现从ListView控件中异地获取文本内容源代码
    VB获得进程PID
    任意组合指令达到免杀
    免杀之等价替换法
    ASP技巧base64编码、解码函数
    看到一个思路新颖的下载者制作法
  • 原文地址:https://www.cnblogs.com/DiZhang/p/12544886.html
Copyright © 2011-2022 走看看