StringUtilspublic final class StringUtils extends Object Utility class for working with and manipulating Strings. |
Constructors Summary |
---|
private StringUtils()
|
Methods Summary |
---|
public static boolean | isEmpty(java.lang.String string)Returns whether or not the String is empty. A String is considered to
be empty if it is null or if it has a length of 0.
return ((string == null) || (string.length() == 0));
| public static boolean | isEmptyOrWhitespace(java.lang.String string)Returns {@code true} if the given string is null, empty, or comprises only
whitespace characters, as defined by {@link Character#isWhitespace(char)}.
if (string == null) {
return true;
}
int length = string.length();
for (int i = 0; i < length; i++) {
if (!Character.isWhitespace(string.charAt(i))) {
return false;
}
}
return true;
| public static int | parseInt(java.lang.String string, int defaultValue)
if (string != null) {
try {
return Integer.parseInt(string);
} catch (NumberFormatException nfe) {
// ignore
}
}
return defaultValue;
|
|