public final class JStringUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
BACKSLASH |
static String |
COMMA |
static String |
EMPTY
Shortcut EMPTY for our projects.
|
static String |
FORWARD_SLASH |
static String |
GET |
static String |
HYPHEN |
static String |
IS |
static String |
NEW_LINE |
static String |
PERCENT |
static String |
PERIOD |
static String |
PLUS |
static String |
QUESTION_MARK |
static String |
SHORT_NO |
static String |
SHORT_YES |
static String |
TAB |
static String |
UNDERSCORE |
static Charset |
UTF8_CHARSET |
static String |
WILD_CARD |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
compare(String str1,
String str2)
This compares two strings with both possible null values.
|
static String |
convertInputStreamToString(InputStream is,
String charset)
To convert the InputStream to String we use the BufferedReader.readLine()
method.
|
static String |
decode(byte[] bytes,
Charset charset)
Decode an array of bytes as UTF8.
|
static byte[] |
encode(String string,
Charset charset) |
static String |
getNonNullValue(String string)
This returns an empty string if null is passed, returns the original string
otherwise.
|
static boolean |
hasDigit(String str)
Returns true if this string contains digits, false otherwise.
|
static boolean |
hasValue(String string)
Returns true if the string has any kind of value.
|
static boolean |
isNullOrEmpty(String string)
Returns true if the provided string is null or empty.
|
static String |
join(Collection<?> collection,
String separator)
Join a collection or list of elements, using the separator provided.
|
static String |
ltrim(String source)
Remove spaces from the beginning.
|
static String |
pad(String rawString,
int length,
char padChar)
Pad string with a character at end of text.
|
static String |
rtrim(String source)
Remove trailing whitespace.
|
static String |
safeTrim(String str)
This method will trim all non-null strings, if the
supplied string is null, then return
EMPTY. |
static List<String> |
split(String str,
String separatorChars)
Split a string into a
List of Strings, given the String
of "seperator" characters. |
static String |
upperCaseFirst(String str)
Upper case the first character of the supplied string.
|
public static final String EMPTY
public static final String WILD_CARD
public static final String UNDERSCORE
public static final String HYPHEN
public static final String BACKSLASH
public static final String QUESTION_MARK
public static final String NEW_LINE
public static final String TAB
public static final String SHORT_NO
public static final String SHORT_YES
public static final String PERCENT
public static final String FORWARD_SLASH
public static final String PLUS
public static final String COMMA
public static final String PERIOD
public static final String GET
public static final String IS
public static final Charset UTF8_CHARSET
public static String safeTrim(String str)
EMPTY.str - - the string to trimpublic static String ltrim(String source)
source - public static String rtrim(String source)
source - public static boolean hasDigit(String str)
str - public static String pad(String rawString, int length, char padChar)
rawString - length - - total length of the desired stringpadChar - - character to pad at the end of the text.public static String convertInputStreamToString(InputStream is, String charset) throws IOException
is - - InputStreamcharset - - String, the character setIOExceptionpublic static String upperCaseFirst(String str)
str - - Stringpublic static String join(Collection<?> collection, String separator)
collection - - Collection>?<separator - - Stringpublic static List<String> split(String str, String separatorChars)
List of Strings, given the String
of "seperator" characters.str - separatorChars - public static String decode(byte[] bytes, Charset charset)
bytes - - byte[]public static byte[] encode(String string, Charset charset)
string - charset - public static boolean isNullOrEmpty(@Nullable String string)
string - public static boolean hasValue(String string)
string - public static boolean compare(@Nullable String str1, @Nullable String str2)
str1 - str2 - Copyright © 2014. All rights reserved.