public final class Strings extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
dquote(String
Returns a double quoted string.
|
static boolean |
isBlank(String
Checks if a String is blank.
|
static boolean |
isEmpty(CharSequence
Checks if a CharSequence is empty ("") or null.
|
static boolean |
isNotBlank(String
Checks if a String is not blank.
|
static boolean |
isNotEmpty(CharSequence
Checks if a CharSequence is not empty ("") and not null.
|
static String |
quote(String
Returns a quoted string.
|
static String |
trimToNull(String
Removes control characters (char <= 32) from both ends of this String returning
null if the String is empty ("") after the trim or if it is
null.
|
public static final StringEMPTY
public static Stringdquote(String str)
str - a String
"str"
public static boolean isBlank(Strings)
null, empty, or when trimmed using
String.trim() is empty.
s - the String to check, may be
null
true if the String is
null, empty, or trims to empty.
public static boolean isEmpty(CharSequencecs)
Checks if a CharSequence is empty ("") or null.
Strings.isEmpty(null) = true
Strings.isEmpty("") = true
Strings.isEmpty(" ") = false
Strings.isEmpty("bob") = false
Strings.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0. It no longer trims the CharSequence. That functionality is available in isBlank().
Copied from Apache Commons Lang org.apache.commons.lang3.StringUtils.isEmpty(CharSequence)
cs - the CharSequence to check, may be null
true if the CharSequence is empty or null
public static boolean isNotBlank(Strings)
isBlank(String).
s - the String to check, may be
null
true if the String is non-
null and has content after being trimmed.
public static boolean isNotEmpty(CharSequencecs)
Checks if a CharSequence is not empty ("") and not null.
Strings.isNotEmpty(null) = false
Strings.isNotEmpty("") = false
Strings.isNotEmpty(" ") = true
Strings.isNotEmpty("bob") = true
Strings.isNotEmpty(" bob ") = true
Copied from Apache Commons Lang org.apache.commons.lang3.StringUtils.isNotEmpty(CharSequence)
cs - the CharSequence to check, may be null
true if the CharSequence is not empty and not null
public static Stringquote(String str)
str - a String
'str'
public static StringtrimToNull(String str)
Removes control characters (char <= 32) from both ends of this String returning null if the String is empty ("") after the trim or if it is null.
The String is trimmed using String. Trim removes start and end characters <= 32.
Strings.trimToNull(null) = null
Strings.trimToNull("") = null
Strings.trimToNull(" ") = null
Strings.trimToNull("abc") = "abc"
Strings.trimToNull(" abc ") = "abc"
Copied from Apache Commons Lang org.apache.commons.lang3.StringUtils.trimToNull(String)
str - the String to be trimmed, may be null
null if only chars <= 32, empty or null String input