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

ListfastSplit(final String text, char separator)
fast Split
return fastSplit(null, text, separator);
String[]fastSplit(String text, char separator)
A faster and simpler character-based string splitter based on http://forums.sun.com/thread.jspa?threadID=766801&start=0&tstart=0
ArrayList<String> result = new ArrayList<String>();
if (text != null && text.length() > 0) {
    int index1 = 0;
    int index2 = text.indexOf(separator);
    while (index2 >= 0) {
        String token = text.substring(index1, index2);
        result.add(token);
        index1 = index2 + 1;
...
Listsplit(byte[] b, int separator)
split
List<byte[]> result = new ArrayList<byte[]>();
int i = 0;
while (i < b.length) {
    int e = indexOf(b, separator, i);
    if (e == -1) {
        break;
    byte[] dest = new byte[e - i];
...
Listsplit(CharSequence seq, char separator)
split
List<String> strs = new ArrayList<>();
StringBuilder buffer = new StringBuilder();
int index = 0;
while (index < seq.length()) {
    char ch = seq.charAt(index++);
    if (ch == ESCAPE_CHAR) {
        if (index < seq.length())
            buffer.append(seq.charAt(index++));
...
String[]split(final String expression, final char separator)
Splits an expression by the specified separator but keeps track of brackets so separator characters inside of a sub type are ignored.
final List<String> parts = new ArrayList<String>();
int start = 0;
int level = 0;
final int len = expression.length();
for (int i = 0; i < len; i += 1) {
    final char c = expression.charAt(i);
    if (c == separator) {
        if (level == 0) {
...
Listsplit(final String input, final String separator)
split
List<String> result = new ArrayList<String>();
if (input == null) {
    return result;
if (separator == null) {
    result.add(input);
    return result;
int separatorLength = separator.length();
int fromIndex = 0;
int separatorIndex = input.indexOf(separator, fromIndex);
while (separatorIndex >= 0) {
    result.add(input.substring(fromIndex, separatorIndex));
    fromIndex = separatorIndex + separatorLength;
    separatorIndex = input.indexOf(separator, fromIndex);
if (fromIndex <= input.length()) {
    result.add(input.substring(fromIndex, input.length()));
return result;
Listsplit(final String iSource, final char iRecordSeparator, final char... iJumpCharacters)
split
return split(iSource, 0, iSource.length(), iRecordSeparator, iJumpCharacters);
String[]split(final String s, final char separator)
Splits a String at character separator and trims spaces if present.
if (s == null)
    return null;
final List<String> result = new ArrayList<String>();
int j = -1;
for (int i = s.indexOf(separator); i != -1; j = i, i = s.indexOf(separator, i + 1)) {
    result.add(s.substring(j + 1, i).trim());
result.add(s.substring(j + 1).trim());
...
String[]split(final String str, final char separator)
Split string by special separator char.
return split(str, separator, 0);
Listsplit(final String str, final char separator)
Split string to array.
List<String> arr = new ArrayList<String>();
int pos = 0, lastPos = 0;
while ((pos = str.indexOf(separator, lastPos)) != -1) {
    arr.add(str.substring(lastPos, pos));
    lastPos = pos + 1;
if (str.length() > lastPos) {
    arr.add(str.substring(lastPos));
...