|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.restfb.util.StringUtils
public final class StringUtils
A collection of string-handling utility methods.
Field Summary | |
---|---|
static String |
ENCODING_CHARSET
Default charset to use for encoding/decoding strings. |
Method Summary | |
---|---|
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 |
urlDecode(String string)
URL-decodes a string. |
static String |
urlEncode(String string)
URL-encodes a string. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String ENCODING_CHARSET
Method Detail |
---|
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)
Assumes 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 String urlDecode(String string)
Assumes string
is in "UTF-8" format.
string
- The string to URL-decode.
null
if
string
is null
.
IllegalStateException
- If unable to URL-decode because the JVM doesn't support
"UTF-8".public static byte[] toBytes(String string)
string
to a byte array.
Assumes string
is in "UTF-8" format.
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
.public static String join(List<String> list)
list
into a comma-separated string.
list
- The list to join.
list
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |