public class StringUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
EMPTY_STRING |
| Constructor and Description |
|---|
StringUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
arrayToString(boolean[] array)
Print out an array as a String
|
static String |
arrayToString(int[] array)
Print out an array as a String
|
static String |
arrayToString(Object[] array)
Print out an array as a String
|
static String |
arrayToString(Object[] array,
char delim)
Print out an array as a String
|
static String |
capitalize(String str)
Capitalizes the first letter of str.
|
static String |
collectionToString(Collection<?> collection) |
static String |
collectionToString(Collection<?> collection,
String delim) |
static List<String> |
explode(String s,
String delim)
Split a string on delimiter boundaries, and place each element into a List.
|
static String[] |
explodeQuoted(String arg)
Split a string up by whitespace, taking into account quoted subcomponents.
|
static String[] |
explodeToArray(String toExplode,
String delim)
Split a string on delimiter boundaries, and place each element into an Array.
|
static String |
formatDuration(long duration) |
static String |
formatDuration(long duration,
int scale,
boolean minDigits) |
static String |
getFirstStackTrace(Throwable t) |
static String |
getStackTrace(Throwable t) |
static String |
implode(List<?> objs,
String delim)
Create a string formulated by inserting a delimiter in between consecutive array elements.
|
static boolean |
isBlank(String s) |
static boolean |
isEmpty(String s) |
static boolean |
isNotBlank(String s) |
static boolean |
isNotEmpty(String s) |
static String |
iteratorToString(Iterator<?> i,
String delim)
Print out everything in an Iterator in a user-friendly string format.
|
static String |
iteratorToString(Iterator<?> i,
String delim,
String quoteChar)
Print out everything in an Iterator in a user-friendly string format.
|
static String |
listToString(List<?> list)
Print out a List in a user-friendly string format.
|
static String |
listToString(List<?> list,
String delim)
Print out a List in a user-friendly string format.
|
static String |
normalizePath(String s) |
static String |
pluralize(String word) |
static String |
remove(String source,
String find) |
static String |
removePrefix(String value,
String prefix)
Remove a prefix from a string.
|
static String |
repeatChars(char c,
int nTimes) |
static String |
replace(String source,
String find,
String replace) |
static String |
truncate(String s,
int truncLength,
boolean removeWhiteSpace) |
public static final String EMPTY_STRING
public static String replace(String source, String find, String replace)
source - The source string to perform replacements on.find - The substring to find in source.replace - The string to replace 'find' within sourcepublic static String remove(String source, String find)
source - The source string to perform replacements on.find - The substring to find in source.public static String iteratorToString(Iterator<?> i, String delim)
i - An iterator to print out.delim - The delimiter to use between elements.public static String iteratorToString(Iterator<?> i, String delim, String quoteChar)
i - An iterator to print out.delim - The delimiter to use between elements.quoteChar - The character to quote each element with.public static String listToString(List<?> list, String delim)
list - A List to print out.delim - The delimiter to use between elements.public static String collectionToString(Collection<?> collection, String delim)
public static String listToString(List<?> list)
list - A List to print out.public static String collectionToString(Collection<?> collection)
public static String arrayToString(boolean[] array)
public static String arrayToString(Object[] array, char delim)
array - The array to print outdelim - The delimiter to use between elements.public static String arrayToString(int[] array)
public static String implode(List<?> objs, String delim)
objs - List of objects to implode (elements may not be null)delim - String to place inbetween elementspublic static List<String> explode(String s, String delim)
s - String to split updelim - Delimiting token, ala StringTokenizerpublic static String[] explodeToArray(String toExplode, String delim)
toExplode - String to split updelim - Delimiting token, ala StringTokenizerpublic static String[] explodeQuoted(String arg) throws IllegalArgumentException
arg - String to parseIllegalArgumentException - indicating there was a quoting errorpublic static String removePrefix(String value, String prefix)
public static String pluralize(String word)
public static String getStackTrace(Throwable t)
public static String getFirstStackTrace(Throwable t)
public static String normalizePath(String s)
s - A string that might contain unix-style path separators.public static String formatDuration(long duration)
public static String formatDuration(long duration, int scale, boolean minDigits)
public static String repeatChars(char c, int nTimes)
public static String capitalize(String str)
str - The string to capitalize.str capitalized. Returns null if str is null.public static boolean isEmpty(String s)
public static boolean isNotEmpty(String s)
public static boolean isBlank(String s)
public static boolean isNotBlank(String s)
Copyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.