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 string)
split
String s = string;
if (s != null)
    s = s.trim();
String[] sArr = s.split("([ \t])+");
List<String> list = new ArrayList<String>();
boolean insideQuote = false;
String tmp = null;
for (int i = 0; i < sArr.length; i++) {
...
String[]split(String string)
Splits a string into an array of components.
ArrayList<String> parts = new ArrayList<String>();
StringBuffer currentPart = new StringBuffer();
int state = STATE_BEGIN;
for (int i = 0; i < string.length(); i++) {
    char ch = string.charAt(i);
    switch (state) {
    case STATE_BEGIN:
        if (ch == '"') {
...
ArrayListsplit(String string, String seperator)
Utility to split a string on a specified substring into an ArrayList

This wraps String.split to return an ArrayList instead of a String[] array.

return new ArrayList<String>(Arrays.asList(string.split(seperator)));
String[]split(String strSource, String strReg)
split
if (strSource == null)
    return null;
if (strReg == null || strReg.equals(""))
    return new String[] { strSource };
ArrayList arrLst = new ArrayList();
splitA(strSource, strReg, arrLst);
String arrRslt[] = new String[arrLst.size()];
return (String[]) arrLst.toArray(arrRslt);
...
String[]split(String text)
Split text into chinese\number\letter\punct.
if (text == null) {
    return new String[0];
List<String> list = new ArrayList<>();
int flag = -1; 
String temp = "";
char[] array = text.toCharArray();
for (char c : array) {
...
Listsplit(String text)
split
final ArrayList<String> result = new ArrayList<>();
String newText = "";
Scanner scan = new Scanner(text).useDelimiter(" ");
while (scan.hasNext()) {
    newText += scan.next();
    final int openingIdx = newText.indexOf("(");
    if (openingIdx == -1) {
        result.add(newText);
...
Listsplit(String text)
split
List<String> parts = new ArrayList<>();
if (text != null) {
    String[] split = text.split(",");
    for (String part : split) {
        parts.add(part.trim());
return parts;
...
Listsplit(String text, String token)
split
List list = new ArrayList();
int start = 0;
int end = -1;
while ((end = text.indexOf(token, start)) != -1) {
    list.add(text.substring(start, end));
    start = end + token.length();
list.add(text.substring(start));
...
String[]split(String token, String s)
split
if (null == s || 0 == s.length())
    return NULL_STRING_ARRAY;
List<String> ls = new ArrayList<String>();
int previousLoc = 0;
int loc = s.indexOf(token, previousLoc);
if (-1 == loc) {
    ls.add(s);
} else {
...
Listsplit(String toSplit)
split
return split(toSplit, null, false);