We will discuss example of StringUtils.isNotBlank() and StringUtils.isNotEmpty() in Java in this tutorial . We see different examples of stringutils isnotblank vs isnotempty . Let’s see isnotblank vs isnotempty coding examples .First we discuss about stringutils.isnotblank() and then stringutils.isnotempty() .
Example of StringUtils.isNotBlank()
Now we see StringUtils.isNotBlank() example . StringUtils.isNotBlank() method have prototype as below.
public static boolean isNotBlank(String str)
Parameters:
str – the String to check
Returns: true if the String is not empty and not null and not whitespace.
stringutils.isnotblank() checks if a String is not empty (“”), not null and not whitespace only.
StringUtils.isNotBlank(null) = false
StringUtils.isNotBlank(“”) = false
StringUtils.isNotBlank(” “) = false
StringUtils.isNotBlank(“java”) = true
StringUtils.isNotBlank(“java “) = true
Example of StringUtils.isNotEmpty() Method
Now we see StringUtils.isNotEmpty() method example . The prototype of StringUtils.isNotEmpty() as
public static boolean isNotEmpty(String str)
Parameters:
str – the String to check, may be null
Returns:
true if the String is not empty and not null
Method StringUtils.isNotEmpty() , checks if a String is not empty (“”) and not null.
StringUtils.isNotEmpty(null) = false
StringUtils.isNotEmpty(“”) = false
StringUtils.isNotEmpty(” “) = true
StringUtils.isNotEmpty(“java”) = true
StringUtils.isNotEmpty(“java “) = true
In this tutorial we learned stringutils.isnotblank() and stringutils.isnotempty() example . We are also seen stringutils isnotempty vs isnotblank example . You can learn more string program in java for practice .