public class StringUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
lineSeparator
Workaround too support android API 16-18.
|
static char |
NO_SEPARATOR
Special character to signal, that no separator should be used when byte
array are converted to hexadecimal strings.
|
static boolean |
SUPPORT_HOST_STRING
Flag indicating, that InetSocketAddress supports "getHostString".
|
| Constructor and Description |
|---|
StringUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
byteArray2Hex(byte[] byteArray)
Byte array to hexadecimal string without separator.
|
static String |
byteArray2HexString(byte[] byteArray,
char sep,
int max)
Byte array to hexadecimal display string.
|
static byte[] |
hex2ByteArray(String hex)
Convert hexadecimal String into decoded byte array.
|
static char[] |
hex2CharArray(String hex)
Convert hexadecimal String into decoded character array.
|
static boolean |
isValidHostName(String name)
Checks if a given string is a valid host name as defined by
RFC 1123.
|
static String |
lineSeparator()
Return line separator.
|
static String |
toString(InetAddress address)
Get address as string for logging.
|
static String |
toString(InetSocketAddress address)
Get socket address as string for logging.
|
static String |
trunc(String text,
int maxLength)
Truncate provided string.
|
public static final char NO_SEPARATOR
public static final String lineSeparator
lineSeparator()public static final boolean SUPPORT_HOST_STRING
public static String lineSeparator()
lineSeparatorpublic static char[] hex2CharArray(String hex)
hex - hexadecimal string. e.g. "4130010A"IllegalArgumentException - if the parameter length is odd or
contains non hexadecimal characters.public static byte[] hex2ByteArray(String hex)
hex - hexadecimal string. e.g. "4130010A"IllegalArgumentException - if the parameter length is odd or
contains non hexadecimal characters.byteArray2Hex(byte[])public static String byteArray2Hex(byte[] byteArray)
byteArray - byte array to be converted to string.null, if the provided
byte array is null. "", if provided byte array is
empty.hex2ByteArray(String)public static String byteArray2HexString(byte[] byteArray, char sep, int max)
byteArray - byte array to be converted to stringsep - separator. If NO_SEPARATOR, then no separator is used
between the bytes.max - maximum bytes to be converted. 0 to convert all bytes.null or empty.public static String trunc(String text, int maxLength)
text - string to be truncated, if length is over the provided
maxLengthmaxLength - maximum length of string. (0 doesn't truncate)public static String toString(InetAddress address)
address - address to be converted to stringnull, if address is null.public static String toString(InetSocketAddress address)
address - socket address to be converted to stringnull, if address is
null.Copyright © 2019 Eclipse Foundation. All rights reserved.