Java Utililty Methods String Split by Delimiter

List of utility methods to do String Split by Delimiter

Description

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

Method

ListsplitOnEntireString(String target, String delimiter)
Break a string into pieces based on matching the full delimiter string in the text.
ArrayList result = new ArrayList();
if (delimiter.length() > 0) {
    int index = 0;
    int indexOfNextMatch = target.indexOf(delimiter);
    while (indexOfNextMatch > -1) {
        result.add(target.substring(index, indexOfNextMatch));
        index = indexOfNextMatch + delimiter.length();
        indexOfNextMatch = target.indexOf(delimiter, index);
...
ListsplitSimple(String delimiter, String str)
Splits the given string str using the given delimiter and returns the result as a string list.
return splitSimple(delimiter, str, 4);
ListsplitSimpleLimit(String str, String delimiter, int limitSize)
split Simple Limit
return splitSimpleLimit(str, delimiter, limitSize, false);
voidsplitSqlScript(String script, char delim, List statements)
Split an SQL script into separate statements delimited with the provided delimiter character.
StringBuilder sb = new StringBuilder();
boolean inLiteral = false;
char[] content = script.toCharArray();
for (int i = 0; i < script.length(); i++) {
    if (content[i] == '\'') {
        inLiteral = !inLiteral;
    if (content[i] == delim && !inLiteral) {
...
ListsplitStr(String str, char delimiter, boolean trim)
Splits string by delimiter.
int startPos = 0;
final List<String> result = new ArrayList<String>();
for (int i = 0; i < str.length(); i++) {
    char c = str.charAt(i);
    if (c == delimiter) {
        String subStr = str.substring(startPos, i);
        if (trim) {
            subStr = subStr.trim();
...
ListsplitString(CharSequence s, char delim)
Split a string into a list of substrings using a specified character as delimiter.
StringBuffer sb = new StringBuffer(s.length());
List<String> list = new ArrayList<String>();
for (int i = 0; i < s.length(); i++) {
    char ch = s.charAt(i);
    if (ch == delim) {
        list.add(sb.toString());
        sb.setLength(0);
    } else {
...
String[]splitString(final String values, final char delimiter)
split String
return splitString(values, delimiter, Integer.MAX_VALUE);
ArrayListsplitString(String data, String delimiter)
Split the input string "data" using the delimiter and return as list of strings for the slices obtained
if (data == null) {
    throw new IllegalArgumentException("Passed in string is null ");
ArrayList<String> toReturn = new ArrayList<String>();
String[] slices = data.split(delimiter);
toReturn.addAll(Arrays.asList(slices));
return toReturn;
VectorsplitString(String originalString, String delimeter)
Split string into multiple strings divided by delimeter string
int i = 0;
Vector result = new Vector();
i = originalString.indexOf(delimeter);
if (i < 0) {
    if (originalString.length() > 0)
        result.addElement(originalString);
    return result;
while (i >= 0) {
    result.addElement((String) originalString.substring(0, i));
    originalString = originalString.substring(i + delimeter.length());
    i = originalString.indexOf(delimeter);
result.addElement(originalString);
return result;
String[]splitString(String source, String delimiter)
split String
List<String> list = new ArrayList<String>();
int idx = 0;
while ((idx = source.indexOf(delimiter)) >= 0) {
    list.add(source.substring(0, idx));
    source = source.substring(idx + 1);
if (source != null && !source.isEmpty()) {
    list.add(source);
...