import org.apache.commons.lang.StringUtils; import org.junit.Test; public class Test{ //總結:isNotBlank()一定要裡面有東西 null,""," ",返回的都是false @Test public vo ...
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()使用總結