public final class StringUtils extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
StringUtils.JoinCallback<T>
Callback interface used with various
StringUtils.join() methods. |
static interface |
StringUtils.JoinMapCallback<K,V>
Callback interface used with the
join(Map, String, JoinMapCallback) method. |
Modifier and Type | Field and Description |
---|---|
static String |
NEWLINE
The local computer's newline character sequence.
|
Modifier and Type | Method and Description |
---|---|
static <T> String |
join(Collection<T> collection,
String delimiter)
Joins a collection of values into a delimited list.
|
static <T> void |
join(Collection<T> collection,
String delimiter,
StringBuilder sb)
Joins a collection of values into a delimited list.
|
static <T> void |
join(Collection<T> collection,
String delimiter,
StringBuilder sb,
StringUtils.JoinCallback<T> join)
Joins a collection of values into a delimited list.
|
static <T> String |
join(Collection<T> collection,
String delimiter,
StringUtils.JoinCallback<T> join)
Joins a collection of values into a delimited list.
|
static <K,V> String |
join(Map<K,V> map,
String delimiter,
StringUtils.JoinMapCallback<K,V> join)
Joins a map into a delimited list.
|
static String |
ltrim(String string)
Trims the whitespace off the left side of a string.
|
static String |
repeat(char c,
int count)
Creates a string consisting of "count" occurrences of char "c".
|
static void |
repeat(char c,
int count,
StringBuilder sb)
Creates a string consisting of "count" occurrences of char "c".
|
static String |
repeat(String str,
int count)
Creates a string consisting of "count" occurrences of string "str".
|
static String |
rtrim(String string)
Trims the whitespace off the right side of a string.
|
public static String ltrim(String string)
string
- the string to trimpublic static String rtrim(String string)
string
- the string to trimpublic static String repeat(char c, int count)
c
- the character to repeatcount
- the number of times to repeat the characterpublic static void repeat(char c, int count, StringBuilder sb)
c
- the character to repeatcount
- the number of times to repeat the charactersb
- the character sequence to append the characters topublic static String repeat(String str, int count)
str
- the string to repeatcount
- the number of times to repeat the stringpublic static <T> String join(Collection<T> collection, String delimiter)
T
- the value classcollection
- the collection of valuesdelimiter
- the delimiter (e.g. ",")public static <T> void join(Collection<T> collection, String delimiter, StringBuilder sb)
T
- the value classcollection
- the collection of valuesdelimiter
- the delimiter (e.g. ",")sb
- the string builder to append ontopublic static <T> String join(Collection<T> collection, String delimiter, StringUtils.JoinCallback<T> join)
T
- the value classcollection
- the collection of valuesdelimiter
- the delimiter (e.g. ",")join
- callback function to call on every element in the collectionpublic static <T> void join(Collection<T> collection, String delimiter, StringBuilder sb, StringUtils.JoinCallback<T> join)
T
- the value classcollection
- the collection of valuesdelimiter
- the delimiter (e.g. ",")sb
- the string builder to append ontojoin
- callback function to call on every element in the collectionpublic static <K,V> String join(Map<K,V> map, String delimiter, StringUtils.JoinMapCallback<K,V> join)
K
- the key classV
- the value classmap
- the mapdelimiter
- the delimiter (e.g. ",")join
- callback function to call on every element in the collectionCopyright © 2013-2016 Michael Angstadt. All Rights Reserved.