public final class StringUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ENCODING_CHARSET
Default charset to use for encoding/decoding strings.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
fromInputStream(InputStream inputStream)
Builds and returns a string representation of the given
inputStream
. |
static boolean |
isBlank(String string)
Is
string blank (null or only whitespace)? |
static String |
join(List<String> list)
Joins the given
list into a comma-separated string. |
static String |
join(String[] array)
Joins the given
array into a comma-separated string. |
static byte[] |
toBytes(String string)
Converts
string to a byte array. |
static String |
trimToEmpty(String string)
Returns a trimmed version of
string, or an empty string if
string is null or the trimmed version is a blank string. |
static String |
trimToNull(String string)
Returns a trimmed version of
string, or null if
string is null or the trimmed version is a blank string. |
static String |
urlEncode(String string)
URL-encodes a string.
|
public static final String ENCODING_CHARSET
public static boolean isBlank(String string)
string blank (null or only whitespace)?string - The string to check.true if string is blank, false otherwise.public static String trimToNull(String string)
string, or null if
string is null or the trimmed version is a blank string.string - The string to trim.string, or null if
string is null or the trimmed version is a blank
string.public static String trimToEmpty(String string)
string, or an empty string if
string is null or the trimmed version is a blank string.string - The string to trim.string, or an empty string if
string is null or the trimmed version is a blank
string.public static String urlEncode(String string)
string is in "UTF-8" format.string - The string to URL-encode.null if
string is null.IllegalStateException - If unable to URL-encode because the JVM doesn't support
"UTF-8".public static byte[] toBytes(String string)
string - The string to convert to a byte array.string.NullPointerException - If string is null.IllegalStateException - If unable to URL-encode because the JVM doesn't support
"UTF-8".public static String fromInputStream(InputStream inputStream) throws IOException
inputStream
.inputStream - The stream from which a string representation is built.inputStream.IOException - If an error occurs while processing the inputStream.public static String join(String[] array)
array into a comma-separated string.array - The array to join.array.Copyright © 2014. All rights reserved.