编程知识 cdmana.com

Java: org.apache.commons . lang3.stringutils determines that the string is empty

rely on

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.10</version>
</dependency>

Code example

package com.demo.file;

import org.apache.commons.lang3.StringUtils;

public class LangDemo {
    
    public static void main(String[] args) {
    
        /* null */
        System.out.println(StringUtils.isBlank(null));
        // true

        System.out.println(StringUtils.isEmpty(null));
        // true

        /*  An empty string  */
        System.out.println(StringUtils.isBlank(""));
        // true

        System.out.println(StringUtils.isEmpty(""));
        // true

        /*  Space  */
        System.out.println(StringUtils.isBlank(" "));
        // true

        System.out.println(StringUtils.isEmpty(" "));
        // false

    }
}

版权声明
本文为[Peng Shiyu]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224171911705k.html

Scroll to Top