@ParametersAreNonnullByDefault public final class Strings extends Object
String.| Modifier and Type | Field and Description |
|---|---|
static String |
EMPTY
The empty string
"". |
static String |
LR
A string for a line separator character, dependencing on the system.
|
static String |
SPACE
A string for a space character.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
emptyToNull(String s)
Returns the given string if it is nonempty;
null otherwise. |
static boolean |
isBinary(String value)
Returns
true if the value represents an hexadecimal value. |
static boolean |
isNullOrEmpty(String s)
Returns
true if the given string is null or is the empty string. |
static String |
nullToEmpty(String s)
Returns the given string if it is non-
null; the empty string otherwise. |
static byte[] |
toBytes(String value)
Encodes a
String to a byte array. |
static byte[] |
toBytesBinary(String value)
Encodes a
String to a byte array, where each byte is represented as a two-digit unsigned
hexadecimal number in lower case. |
@Nonnull public static final String EMPTY
"".@Nonnull public static final String SPACE
@Nonnull public static final String LR
System.lineSeparator()public static boolean isNullOrEmpty(@Nullable String s)
true if the given string is null or is the empty string.s - a string reference to checktrue if the string is null or is the empty string@Nonnull public static String nullToEmpty(@Nullable String s)
null; the empty string otherwise.s - the string to test and possibly returns itself if it is non-null; EMPTY if it is null@CheckForNull public static String emptyToNull(@Nullable String s)
null otherwise.s - the string to test and possibly returns itself if it is nonempty; null if it is empty or null@Nonnull public static byte[] toBytes(String value)
String to a byte array.value - the value to encodebyte arrayNullPointerException - if the value is nullIllegalArgumentException - if StandardCharsets.UTF_8 is not a supported encoding@Nonnull public static byte[] toBytesBinary(String value)
String to a byte array, where each byte is represented as a two-digit unsigned
hexadecimal number in lower case.value - the value to encodebyte arrayNullPointerException - if the value is nullIllegalArgumentException - if the length of the value is not even.Bytes.toStringBinary(byte[])public static boolean isBinary(String value)
true if the value represents an hexadecimal value.value - the string to testtrue if the value represents an hexadecimal valueCopyright © 2017–2019 Atlanmod. All rights reserved.