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

String[]split(String s, char delimiter)
split
s = s.trim();
if (s.isEmpty()) {
    return _emptyStringArray;
List<String> values = new ArrayList<>();
int offset = 0;
int pos = s.indexOf(delimiter, offset);
while (pos != -1) {
...
Listsplit(String s, String delim)
split
List<String> list = new ArrayList<String>();
s = trim(s);
if (s == null) {
    return list;
String[] rs = s.split(delim);
for (String str : rs)
    if (str.trim().length() > 0) {
...
String[]split(String s, String delim)
split
Vector v = new Vector();
StringTokenizer st = new StringTokenizer(s, delim);
while (st.hasMoreTokens())
    v.addElement(st.nextToken());
String[] sa = new String[v.size()];
v.copyInto(sa);
return sa;
Listsplit(String s, String delim)
split
return Arrays.asList(s.split(","));
Listsplit(String s, String delimiter)
split
List<String> ret = new ArrayList<>();
if (isBlank(s)) {
    return ret;
String ss[] = s.split(delimiter);
for (String ass : ss) {
    if (isBlank(ass)) {
        continue;
...
String[]split(String s, String delimiter)
split
if (s.endsWith(delimiter)) {
    s += delimiter;
ArrayList<String> al = new ArrayList<String>();
int p1 = 0, p2 = 0;
String prev = delimiter;
while ((p2 = s.indexOf(delimiter, p1)) != -1) {
    String fld = s.substring(p1, p2);
...
String[]split(String s, String delimiter)
split
StringTokenizer tk = new StringTokenizer(s, delimiter);
List<String> list = new ArrayList<>();
while (tk.hasMoreTokens()) {
    list.add(tk.nextToken());
return list.toArray(new String[list.size()]);
String[]split(String src, char delim)
A String#split(*) replacement that splits on the provided char.
if (src == null) {
    return EMPTY_STRING_ARRAY;
if (src.length() == 0) {
    return new String[] { ZERO_LENGTH_STRING };
ArrayList result = new ArrayList();
int idx = src.indexOf(delim);
...
String[]split(String src, char delim)
Faster implementation of string splitting on a single character delimiter.
return split(src, delim, 0);
String[]split(String src, String delimiter)
split
if (src == null || delimiter == null || src.trim().equals("") || delimiter.equals("")) {
    return new String[] { src };
ArrayList<String> list = new ArrayList<String>();
int lengthOfDelimiter = delimiter.length();
int pos = 0;
while (true) {
    if (pos < src.length()) {
...