Java Utililty Methods String Split by Separator

List of utility methods to do String Split by Separator

Description

The list of methods to do String Split by Separator are organized into topic(s).

Method

ListsplitStringToLong(String strInput, String separator)
Split String to List of long by separator
List<Long> lstResult = new ArrayList<Long>();
if (strInput != null && !strInput.isEmpty()) {
    String[] strTemp = strInput.split(separator);
    if (strTemp != null && strTemp.length > 0) {
        for (int i = 0; i < strTemp.length; i++) {
            lstResult.add(Long.valueOf(strTemp[i]));
    return lstResult;
return null;
ListsplitStringWithBracesOnSeparator(String string, char separator)
Split string no separator char, taking into account braces.
List<String> tokens = new ArrayList<String>();
if (string != null && string.length() > 0) {
    int depth = 0;
    StringBuilder current = new StringBuilder();
    for (int i = 0; i < string.length(); i++) {
        char c = string.charAt(i);
        if (depth <= 0 && c == separator) {
            tokens.add(current.toString());
...
String[]splitStructs(String str, char separator)
split Structs
if (str == null) {
    return null;
int len = str.length();
if (len == 0) {
    return null;
ArrayList<String> list = new ArrayList<String>();
...
ListsplitToList(String s, String separator)
split To List
if (isNullOrEmpty(s))
    return Collections.emptyList();
return Arrays.asList(s.split(separator));
ListsplitValues(String concatedValues, String separator)
split Values
List<String> values = new ArrayList<String>();
if (concatedValues != null && concatedValues.trim().length() > 0) {
    String[] codes = concatedValues.split(separator);
    for (int i = 0; i < codes.length; i++) {
        values.add(codes[i]);
return values;
...
ListsplitValues(String values, String separator)
Extracts from a string, the substrings contained in it as a separator character.
List<String> valuesList = new ArrayList<String>();
if (values != null && values.length() > 0) {
    String[] splittedValues = values.split(separator);
    for (int i = 0; i < splittedValues.length; i++) {
        if (splittedValues[i].length() > 0) {
            valuesList.add(splittedValues[i]);
return valuesList;
String[]splitWithBreakingBrace(String str, char separator, char braceStart, char braceEnd)
split With Breaking Brace
return splitWithBreakingBrace(str, new char[] { separator }, braceStart, braceEnd);
String[]splitWithoutEscaped(String str, char separatorChar)
split Without Escaped
return splitWithoutEscaped(str, separatorChar, false);
String[]splitWorker(final String str, final char separatorChar, final boolean preserveAllTokens)
Performs the logic for the split and splitPreserveAllTokens methods that do not return a maximum array length.
if (str == null) {
    return null;
final int len = str.length();
if (len == 0) {
    return EMPTY_STRING_ARRAY;
final List<String> list = new ArrayList<String>();
...
String[]stringSplit(String string, int separator, int escape)
string Split
int i = stringIndexOf(string, separator, escape);
return i >= 0 ? new String[] { unescape(string.substring(0, i), escape), string.substring(i + 1) }
        : new String[] { unescape(string, escape), null };