public final class Strings extends Object
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isEmpty(CharSequence cs)
Checks if a CharSequence is empty ("") or null.
|
static boolean |
isNotEmpty(CharSequence cs)
Checks if a CharSequence is not empty ("") and not null.
|
static String |
trimToNull(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. |
public static final String EMPTY
public static boolean isEmpty(CharSequence cs)
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 nulltrue if the CharSequence is empty or nullpublic static boolean isNotEmpty(CharSequence cs)
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 nulltrue if the CharSequence is not empty and not nullpublic static String trimToNull(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().
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 nullnull if only chars <= 32, empty or null String inputCopyright © 1999-2014 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.