Java Utililty Methods String Split

List of utility methods to do String Split

Description

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

Method

String[]split(String str)
Split a string using the default separator
return split(str, ESCAPE_CHAR, COMMA);
String[]split(String str)
Split a string using the default separator
return split(str, ESCAPE_CHAR, COMMA);
Listsplit(String str)
split
List<String> l = new ArrayList<String>();
boolean esc = false;
boolean quoted = false;
StringBuilder w = new StringBuilder();
for (char c : str.toCharArray()) {
    if (c == '\'' && !esc) {
        quoted = !quoted;
    } else if (c == '\\' && !esc) {
...
String[]split(String str)
Split a string using the default separator
return split(str, ESCAPE_CHAR, COMMA);
String[]split(String str)
split
char[] chars = str.toCharArray();
List<String> tokens = new ArrayList<>();
StringBuilder buf = new StringBuilder();
for (char aChar : chars) {
    if ((aChar >= 'a' && aChar <= 'z') || aChar == '\'') {
        buf.append(aChar);
    } else {
        if (buf.length() > 0) {
...
Listsplit(String str, int ch)
split
int begin = 0;
for (; begin < str.length(); begin++) {
    if (str.charAt(begin) != ch) {
        break;
if (begin > 0) {
    str = str.substring(begin);
...
ArrayListsplit(String str, String id)
split
ArrayList vt = new ArrayList();
if ((str != null) && (id != null) && (!str.equals("")) && (!id.equals(""))) {
    int beginindex = 0 - id.length();
    int endindex = 0;
    int end = str.lastIndexOf(id);
    if (end == -1) {
        vt.add(str);
    } else {
...
String[]split(String str, String splitStr)
split
List<String> dataList = new ArrayList<String>();
int indx = str.indexOf(splitStr);
while (indx >= 0) {
    dataList.add(str.substring(0, indx));
    str = str.substring(indx + splitStr.length());
    indx = str.indexOf(splitStr);
dataList.add(str);
...
Listsplit(String str, String splitter)
Split a string into pieces based on delimiters.
StringTokenizer tokens = new StringTokenizer(str, splitter);
ArrayList<String> l = new ArrayList<String>(tokens.countTokens());
while (tokens.hasMoreTokens()) {
    l.add(tokens.nextToken());
return l;
String[]split(String str, String token)
split a String, if there are no character between two token this method place a empty String ( != String.split )
int i = str.indexOf(token);
int start = 0;
ArrayList<String> arrayList = new ArrayList<String>();
while (i >= 0) {
    arrayList.add(str.substring(start, i));
    start = i + 1;
    i = str.indexOf(token, start);
arrayList.add(str.substring(start, str.length()));
String[] res = new String[arrayList.size()];
arrayList.toArray(res);
return res;