isNotBlank的用法

isNotEmpty将空格也作为参数,isNotBlank则排除空格参数

Quote
StringUtils方法的操作对象是java.lang.String类型的对象,是JDK提供的String类型操作方法的补充,并且是null安全的(即如果输入参数String为null则不会抛出NullPointerException,而是做了相应处理,例如,如果输入为null则返回也是null等,具体可以查看源代码)。

除了构造器,StringUtils中一共有130多个方法,并且都是static的,所以我们可以这样调用StringUtils.xxx()

public static boolean isEmpty(String str)
判断某字符串是否为空,为空的标准是str==null或str.length()==0

public static boolean isNotEmpty(String str)
判断某字符串是否非空,等于!isEmpty(String str)

public static boolean isBlank(String str)
判断某字符串是否为空或长度为0或由空白符(whitespace)构成

public static boolean isNotBlank(String str)
判断某字符串是否不为空且长度不为0且不由空白符(whitespace)构成,等于!isBlank(String str)

其他方法介绍:
5. public static String trim(String str)
去掉字符串两端的控制符(control characters, char <= 32),如果输入为null则返回null

public static String trimToNull(String str)
去掉字符串两端的控制符(control characters, char <= 32),如果变为null或"",则返回null

public static String trimToEmpty(String str)
去掉字符串两端的控制符(control characters, char <= 32),如果变为null或"",则返回""

public static String strip(String str)
去掉字符串两端的空白符(whitespace),如果输入为null则返回null

public static String stripToNull(String str)
去掉字符串两端的空白符(whitespace),如果变为null或"",则返回null

public static String stripToEmpty(String str)
去掉字符串两端的空白符(whitespace),如果变为null或"",则返回""
————————————————
版权声明:本文为CSDN博主「一蓑烟雨任平生--」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/csdnlcw/article/details/83546742

原文地址:https://www.cnblogs.com/deepalley/p/15247711.html