public class StringUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
getAsciiBytes(java.lang.String string)
Encodes the given String into a sequence of bytes using the Ascii
character set.
|
static byte[] |
getLatin1Bytes(java.lang.String string)
Encodes the given String into a sequence of bytes using the Latin1
character set.
|
static java.lang.String |
htmlEscape(java.lang.String str)
Returns the given
String according to the HTML 4.0 encoding
rules. |
static java.lang.String |
htmlUnescape(java.lang.String str)
Returns the given
String decoded according to the HTML 4.0
decoding rules. |
static boolean |
isNullOrEmpty(java.lang.String string)
Returns
true if the given string is null or is the empty string. |
static java.lang.String |
nullToEmpty(java.lang.String string)
Returns the given string if it is non-null; the empty string otherwise.
|
static java.util.List<java.lang.String> |
splitAndTrim(java.lang.String stringToSlit)
Returns an list of trimmed token splitted with the split character ",".
|
static java.util.List<java.lang.String> |
splitAndTrim(java.lang.String stringToSlit,
java.lang.String splitCharacter)
Returns an list of trimmed token splitted with the split character.
|
static java.lang.String |
strip(java.lang.String source,
char delimiter)
Strips a delimiter character from both ends of the source string.
|
static java.lang.String |
strip(java.lang.String source,
char delimiter,
boolean start,
boolean end)
Strips a delimiter character from a source string.
|
public static byte[] getAsciiBytes(java.lang.String string)
string - The string to encode.public static byte[] getLatin1Bytes(java.lang.String string)
string - The string to encode.public static java.lang.String htmlEscape(java.lang.String str)
String according to the HTML 4.0 encoding
rules.str - The String to encode.String according to the HTML 4.0 encoding
rules.public static java.lang.String htmlUnescape(java.lang.String str)
String decoded according to the HTML 4.0
decoding rules.str - The String to decode.String decoded according to the HTML 4.0
decoding rules.public static java.lang.String strip(java.lang.String source,
char delimiter)
source - The source string to strip.delimiter - The character to remove.public static java.lang.String strip(java.lang.String source,
char delimiter,
boolean start,
boolean end)
source - The source string to strip.delimiter - The character to remove.start - Indicates if start of source should be stripped.end - Indicates if end of source should be stripped.public static java.lang.String nullToEmpty(java.lang.String string)
string - the string to test and possibly returnstring itself if it is non-null; "" if it is nullpublic static boolean isNullOrEmpty(java.lang.String string)
true if the given string is null or is the empty string.
Consider normalizing your string references with nullToEmpty(java.lang.String). If
you do, you can use String.isEmpty() instead of this method, and
you won't need special null-safe forms of methods like
String.toUpperCase(java.util.Locale) either.
string - a string reference to checktrue if the string is null or is the empty stringpublic static java.util.List<java.lang.String> splitAndTrim(java.lang.String stringToSlit)
stringToSlit - The String to splitpublic static java.util.List<java.lang.String> splitAndTrim(java.lang.String stringToSlit,
java.lang.String splitCharacter)
stringToSlit - The String to splitsplitCharacter - The split CharacterCopyright © 2005-2014 Restlet.