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

booleanisEmpty(String sTest_)
Tests, if a given String equals null or "".
if (sTest_ == null || sTest_.equals("")) {
    return true;
return false;
booleanisEmpty(String str)
Beware, the valid word "null" is also rendered as empty.
return str == null || "".contentEquals(str) || "null".contentEquals(str);
booleanisEmpty(String str)
Name: The string is null or empty Description: When the string is null or empty return true,otherwise false
 String str=null; String str1=""; String str2="abc"; System.out.println(isEmpty(str));//true System.out.println(isEmpty(str1));//true System.out.println(isEmpty(str2));//false 
return str == null || str.isEmpty();
booleanisEmpty(String str)
is Empty
if (str != null) {
    int len = str.length();
    for (int x = 0; x < len; ++x) {
        if (str.charAt(x) > ' ') {
            return false;
return true;
booleanisEmpty(String text)
Check whether stirng is empty (empty or null).
return text == null || text.isEmpty();
booleanisEmptyturnlane(String turns)
is Emptyturnlane
List<String> turnsList = Arrays.asList("reverse", "sharp_left", "left", "slight_left", "merge_to_right",
        "through", "reversible", "merge_to_left", "slight_right", "right", "sharp_right");
for (String tl : turnsList) {
    if (turns.contains(tl)) {
        return true;
return false;
...
booleanisNotEmpty(String str)
Name: The string is not null and empty Description: When the string is not null and empty return true,otherwise false
 String str=null; String str1=""; String str2="abc"; System.out.println(isNotEmpty(str));//false System.out.println(isNotEmpty(str1));//false System.out.println(isNotEmpty(str2));//true 
return !isEmpty(str);
voidisNullOrEmpty(String message, String string)
is Null Or Empty
if ((null == string) || (string.isEmpty())) {
    throw new IllegalArgumentException(message);
booleanisNullOrEmpty(String value)
is Null Or Empty
return value == null || value.trim().isEmpty();
String[]splitAt(String s, String delimiter, boolean includeEmpty)
split At
Vector<String> v = new Vector<String>();
int i;
while ((i = s.indexOf(delimiter)) >= 0) {
    if (includeEmpty || i > 0) {
        v.addElement(s.substring(0, i));
    s = s.substring(i + delimiter.length());
if (includeEmpty || s.length() > 0)
    v.addElement(s);
String[] r = new String[v.size()];
v.copyInto(r);
return r;