Java Utililty Methods String Empty

List of utility methods to do String Empty

Description

The list of methods to do String Empty are organized into topic(s).

Method

StringemptyStringIfNull(String s)
empty String If Null
return (s == null || s.equals("")) ? "-" : s;
StringemptyStringIfNull(String string)
Returns an empty string if null.
if (!hasLength(string)) {
    return "";
return string;
String[]emptyStrings()
empty Strings
return emptyStrings_;
LongemptyStringToLongZero(String s)
empty String To Long Zero
if (s.length() == 0) {
    return 0L;
} else {
    return Long.parseLong(s);
StringemptyStringToNull(String value)
empty String To Null
return value.length() == 0 ? null : value;
StringfirstNotEmpty(String... values)
first Not Empty
for (String value : values) {
    if (value != null && !value.isEmpty())
        return value;
return null;
StringgetFirstNotEmpty(String str, String sperator)
get First Not Empty
List<String> parts = Arrays.asList(str.split("/"));
for (String part : parts) {
    if (!isEmpty(part)) {
        return part;
return str;
booleanisAnyEmpty(String... sAry)
is Any Empty
for (String s : sAry) {
    if (isEmpty(s))
        return true;
return false;
booleanisEmpty(String input)
is Empty
return input == null || input.trim().length() == 0;
booleanisEmpty(String param)
is Empty
return param == null || param.length() == 0 || param.trim().equals("");