public final class Strings extends Object
String or CharSequence
instances.
jupiter
org.jupiter.common.util| 限定符和类型 | 方法和说明 |
|---|---|
static String |
emptyToNull(String string)
Returns the given string if it is nonempty;
null otherwise. |
static boolean |
isBlank(String str)
Checks if a string is whitespace, empty ("") or null.
|
static boolean |
isNotBlank(String str)
Checks if a string is not empty (""), not null and not whitespace only.
|
static boolean |
isNullOrEmpty(String str)
Returns
true if the given string is null or is the empty string. |
static String |
nullToEmpty(String string)
Returns the given string if it is non-null; the empty string otherwise.
|
static String[] |
split(String str,
char separator)
Splits the provided text into an array, separator specified.
|
static String[] |
split(String str,
char separator,
boolean preserveAllTokens)
Splits the provided text into an array, separator specified,
if
true, preserving all tokens, including empty tokens created
by adjacent separators. |
public static String nullToEmpty(String string)
public static String emptyToNull(String string)
null otherwise.public static boolean isNullOrEmpty(String str)
true if the given string is null or is the empty string.public static boolean isBlank(String str)
public static boolean isNotBlank(String str)
public static String[] split(String str, char separator)
public static String[] split(String str, char separator, boolean preserveAllTokens)
true, preserving all tokens, including empty tokens created
by adjacent separators.
A null input String returns null.
Strings.split(null, *, true) = null
Strings.split("", *, true) = []
Strings.split("a.b.c", '.', true) = ["a", "b", "c"]
Strings.split("a..b.c", '.', true) = ["a", "", "b", "c"]
Strings.split("a:b:c", '.', true) = ["a:b:c"]
Strings.split("a b c", ' ', true) = ["a", "b", "c"]
Strings.split("a b c ", ' ', true) = ["a", "b", "c", ""]
Strings.split("a b c ", ' ', true) = ["a", "b", "c", "", ""]
Strings.split(" a b c", ' ', true) = ["", a", "b", "c"]
Strings.split(" a b c", ' ', true) = ["", "", a", "b", "c"]
Strings.split(" a b c ", ' ', true) = ["", a", "b", "c", ""]Copyright © 2018. All rights reserved.