StringUtils.defaultIfBlank
在字符串为null,空串或者空白串的时候,返回指定的默认值。

org.apache.commons.lang.StringUtils defaultIfBlank方法 写道
public static String defaultIfBlank(String str, String defaultStr)

Returns either the passed in String, or if the String is whitespace, empty ("") or null, the value of defaultStr.

StringUtils.defaultIfBlank(null, "NULL") = "NULL"
StringUtils.defaultIfBlank("", "NULL") = "NULL"
StringUtils.defaultIfBlank(" ", "NULL") = "NULL"
StringUtils.defaultIfBlank("bat", "NULL") = "bat"
StringUtils.defaultIfBlank("", null) = null


Parameters:
str - the String to check, may be null
defaultStr - the default String to return if the input is whitespace, empty ("") or null, may be null
Returns:
the passed in String, or the default

//转载哪忘了,别人网上找到发给我的,抱歉!若作者发现麻烦评论区留一下地址,谢谢。

posted on 2018-04-23 11:42  github_white  阅读(978)  评论(0编辑  收藏  举报