public final class DatatypeHelper extends Object
Modifier and Type | Method and Description |
---|---|
static byte[] |
fileToByteArray(File file)
Reads the contents of a file in to a byte array.
|
static String |
inputstreamToString(InputStream input,
CharsetDecoder decoder)
Reads an input stream into a string.
|
static byte[] |
intToByteArray(int integer)
Converts an integer into an unsigned 4-byte array.
|
static boolean |
isEmpty(String s)
A "safe" null/empty check for strings.
|
static String |
listToStringValue(List<String> values,
String delimiter)
Converts a List of strings into a single string, with values separated by a
specified delimiter.
|
static <T> boolean |
safeEquals(T s1,
T s2)
Compares two strings for equality, allowing for nulls.
|
static String |
safeTrim(String s)
A safe string trim that handles nulls.
|
static String |
safeTrimOrNullString(String s)
Removes preceeding or proceeding whitespace from a string or return null if the string is null or of zero length
after trimming (i.e.
|
static List<String> |
stringToList(String string,
String delimiter)
Converts a delimited string into a list.
|
public static boolean isEmpty(String s)
s
- The string to checkpublic static <T> boolean safeEquals(T s1, T s2)
T
- type of object to compares1
- The first operands2
- The second operandpublic static String safeTrim(String s)
s
- the string to trimpublic static String safeTrimOrNullString(String s)
s
- the string to trimpublic static byte[] intToByteArray(int integer)
integer
- integer to convertpublic static byte[] fileToByteArray(File file) throws IOException
file
- file to readIOException
- throw if there is a problem reading the file in to the byte arraypublic static String inputstreamToString(InputStream input, CharsetDecoder decoder) throws IOException
input
- the input stream to readdecoder
- character decoder to use, if null, system default character set is usedIOException
- thrown if there is a problem reading from the stream and decoding itpublic static List<String> stringToList(String string, String delimiter)
string
- the string to be split into a listdelimiter
- the delimiter between values. This string may contain
multiple delimiter characters, as allowed by
StringTokenizer
public static String listToStringValue(List<String> values, String delimiter)
values
- list of stringsdelimiter
- the delimiter used between valuesCopyright © 2018 JBoss by Red Hat. All rights reserved.