public class StringUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
EMPTY_STRING |
| Constructor and Description |
|---|
StringUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
emptyToNull(String string)
Returns the given string if it is nonempty;
null otherwise. |
static boolean |
isNullOrEmpty(String str) |
static String |
join(CharSequence delimiter,
Iterable<? extends CharSequence> elements)
Wrapper of
String.join(CharSequence, Iterable). |
static <T> String |
join(String... elements)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(String[] array,
String separator) |
static <T> String |
joinUsingDelim(String delim,
String... elements) |
static boolean |
nonEmpty(String str) |
static String |
nullToEmpty(String string)
Returns the given string if it is non-null; the empty string otherwise.
|
static String |
objToString(Object obj) |
static List<String> |
split(String input,
String delimiter)
Splits input string, delimited
delimiter into a list of non-empty strings
(skipping any empty string produced during splitting) |
static String |
toHexString(byte[] bytes) |
public static final String EMPTY_STRING
public static <T> String join(String... elements)
Joins the elements of the provided array into a single String containing the provided list of elements.
No separator is added to the joined String. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null) = null StringUtils.join([]) = "" StringUtils.join([null]) = "" StringUtils.join(["a", "b", "c"]) = "abc" StringUtils.join([null, "", "a"]) = "a"
public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements)
public static String toHexString(byte[] bytes)
public static boolean isNullOrEmpty(String str)
public static boolean nonEmpty(String str)
public static String nullToEmpty(@Nullable String string)
string - the string to test and possibly returnstring itself if it is non-null; "" if it is null@Nullable public static String emptyToNull(@Nullable String string)
null otherwise.string - the string to test and possibly returnstring itself if it is nonempty; null if it is empty or nullCopyright © 2022 The Apache Software Foundation. All rights reserved.