Package com.restfb.util
Klasse StringUtils
java.lang.Object
com.restfb.util.StringUtils
A collection of string-handling utility methods.
- Seit:
- 1.6
- Autor:
- Mark Allen
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final Charset
Default charset to use for encoding/decoding strings. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic String
fromInputStream
(InputStream inputStream) Builds and returns a string representation of the giveninputStream
.static boolean
Isstring
blank (null or only whitespace)?static byte[]
Convertsstring
to a byte array.static Integer
Returns anInteger
representation of the givenstring
, ornull
if it's not a validInteger
.static String
toString
(byte[] data) Convertsdata
to a string inENCODING_CHARSET
format.static String
trimToEmpty
(String string) Returns a trimmed version ofstring
, or an empty string ifstring
isnull
or the trimmed version is a blank string.static String
trimToNull
(String string) Returns a trimmed version ofstring
, ornull
ifstring
isnull
or the trimmed version is a blank string.
-
Felddetails
-
ENCODING_CHARSET
Default charset to use for encoding/decoding strings.
-
-
Methodendetails
-
isBlank
Isstring
blank (null or only whitespace)?- Parameter:
string
- The string to check.- Gibt zurück:
true
ifstring
is blank,false
otherwise.
-
trimToNull
Returns a trimmed version ofstring
, ornull
ifstring
isnull
or the trimmed version is a blank string.- Parameter:
string
- The string to trim.- Gibt zurück:
- A trimmed version of
string
, ornull
ifstring
isnull
or the trimmed version is a blank string.
-
trimToEmpty
Returns a trimmed version ofstring
, or an empty string ifstring
isnull
or the trimmed version is a blank string.- Parameter:
string
- The string to trim.- Gibt zurück:
- A trimmed version of
string
, or an empty string ifstring
isnull
or the trimmed version is a blank string.
-
toBytes
Convertsstring
to a byte array.Assumes
string
is inENCODING_CHARSET
format.- Parameter:
string
- The string to convert to a byte array.- Gibt zurück:
- A byte array representation of
string
. - Löst aus:
NullPointerException
- Ifstring
isnull
.IllegalStateException
- If unable to convert because the JVM doesn't supportENCODING_CHARSET
.
-
toString
Convertsdata
to a string inENCODING_CHARSET
format.- Parameter:
data
- The data to convert to a string.- Gibt zurück:
- A string representation of
data
. - Löst aus:
NullPointerException
- Ifdata
isnull
.IllegalStateException
- If unable to convert because the JVM doesn't supportENCODING_CHARSET
.- Seit:
- 1.6.13
-
fromInputStream
Builds and returns a string representation of the giveninputStream
.- Parameter:
inputStream
- The stream from which a string representation is built.- Gibt zurück:
- A string representation of the given
inputStream
. - Löst aus:
IOException
- If an error occurs while processing theinputStream
.
-
toInteger
Returns anInteger
representation of the givenstring
, ornull
if it's not a validInteger
.- Parameter:
string
- The string to process.- Gibt zurück:
- The
Integer
representation ofstring
, ornull
ifstring
isnull
or not a validInteger
.
-