public class StringSplitUtils extends Object
String
manipulation methods. Copied from deleted org.springframework.security.util.StringSplitUtilsConstructor and Description |
---|
StringSplitUtils() |
Modifier and Type | Method and Description |
---|---|
static String[] |
split(String toSplit,
String delimiter)
Splits a
String at the first instance of the delimiter. |
static Map<String,String> |
splitEachArrayElementAndCreateMap(String[] array,
String delimiter,
String removeCharacters)
Takes an array of
String s, and for each element removes any instances of
removeCharacter , and splits the element based on the delimiter . |
static String[] |
splitIgnoringQuotes(String str,
char separatorChar)
Splits a given string on the given separator character, skips the contents of quoted substrings
when looking for separators.
|
public static String[] split(String toSplit, String delimiter)
String
at the first instance of the delimiter.Does not include the delimiter in the response.
toSplit
- the string to splitdelimiter
- to split the string up withIllegalArgumentException
- if an argument was invalidpublic static Map<String,String> splitEachArrayElementAndCreateMap(String[] array, String delimiter, String removeCharacters)
String
s, and for each element removes any instances of
removeCharacter
, and splits the element based on the delimiter
. A Map
is
then generated, with the left of the delimiter providing the key, and the right of the delimiter providing the
value.Will trim both the key and value before adding to the Map
.
array
- the array to processdelimiter
- to split each element using (typically the equals symbol)removeCharacters
- one or more characters to remove from each element prior to attempting the split
operation (typically the quotation mark symbol) or null
if no removal should occurMap
representing the array contents, or null
if the array to process was
null or emptypublic static String[] splitIgnoringQuotes(String str, char separatorChar)
This was copied and modified from commons-lang StringUtils
Copyright © 2019. All rights reserved.