Java Utililty Methods String Split by Char

List of utility methods to do String Split by Char

Description

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

Method

ListfastSplit(final String string, final char sep)
fast Split
final List<String> l = new ArrayList<String>();
final int length = string.length();
final char[] cars = string.toCharArray();
int rfirst = 0;
for (int i = 0; i < length; i++) {
    if (cars[i] == sep) {
        l.add(new String(cars, rfirst, i - rfirst));
        rfirst = i + 1;
...
ListfastSplitTrimmed(final String string, final char sep)
fast Split Trimmed
final List<String> l = new ArrayList<String>();
final int length = string.length();
final char[] cars = string.toCharArray();
int rfirst = 0;
for (int i = 0; i < length; i++) {
    if (cars[i] == sep) {
        l.add(new String(cars, rfirst, i - rfirst).trim());
        rfirst = i + 1;
...
ListsafeSplit(String string, char divider)
safe Split
List<String> result = new ArrayList<String>();
if (string.length() == 0) {
    result.add("");
    return result;
boolean literal = false;
boolean escape = false;
int startpos = 0;
...
Listsplit(char c, String s)
Splits the given String by the given char, vaguely similar to the Perl function 'split'.
List<String> strings = new ArrayList<String>();
int start = 0;
for (int i = 0; i < s.length(); i++) {
    if (s.charAt(i) != c)
        continue;
    strings.add(s.substring(start, i));
    start = i + 1;
if (start <= s.length())
    strings.add(s.substring(start));
return strings;
String[]split(char elem, String orig)
split on the given character, with the resulting tokens not including that character
return split("" + elem, orig);
Listsplit(char sep, String input)
split
return split(Character.toString(sep), input);
String[]split(final String input, final char split)
Similar to the normal String split function.
int index = indexOf(input, split);
int prevIndex = 0;
final ArrayList<String> output = new ArrayList<String>();
if (index == -1) {
    output.add(input);
    return output.toArray(new String[1]);
while (index != -1) {
...
Listsplit(final String string, final char... toSplit)
Splits some string given many chars
final ArrayList<String> ret = new ArrayList<String>();
final int len = string.length();
int last = 0;
char c = 0;
for (int i = 0; i < len; i++) {
    c = string.charAt(i);
    if (contains(c, toSplit)) {
        if (last != i) {
...
Listsplit(String cs, char sep)
Splits a String around occurences of a character.
List<String> list = new ArrayList<>(4);
split(cs, sep, list);
return list;
Listsplit(String s, char c)
split
int beginIndex = 0;
int endIndex;
ArrayList<String> findings = new ArrayList<String>();
while ((endIndex = s.indexOf(c, beginIndex)) > -1) {
    findings.add(s.substring(beginIndex, endIndex));
    beginIndex = endIndex + 1;
if (s.length() > 0)
...