isNotBlank()和isNotEmpty()總結

import org.apache.commons.lang.StringUtils;
import org.junit.Test;


public class Test{

    //總結:isNotBlank()必定要裏面有東西 null,""," ",返回的都是false
    @Test
    public void testDemo1(){
        String str = " ";
        System.out.println(StringUtils.isNotBlank(str));//true
    }

    //總結:isNotEmpty()是將空格也算在裏面,null,"",返回的是fasle," "返回的是true
    @Test
    public void testDemo2(){
        String str = "";
        System.out.println(StringUtils.isNotEmpty(str));
    }


    
}

org.apache.commons.lang工具包下面的isNotBlank()和isNotEmpty()使用總結apache

相關文章
相關標籤/搜索