StringUtils依赖包:
<!-- 判断字符串是否为空 --> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.8.1</version> </dependency>
StringUtils测试编码:
import org.apache.commons.lang3.StringUtils; public class Action { public static void main(String[] args) { String a=null; String b=""; if(StringUtils.isEmpty(a)){ System.out.println("a空"); } if(StringUtils.isEmpty(b)){ System.out.println("b空"); } } }
StringUtils测试效果: