Java Utililty Methods String Split by Line

List of utility methods to do String Split by Line

Description

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

Method

ArrayListsplit(String line, String separator)
split
ArrayList<String> items = new ArrayList<String>();
int start, end;
int sep_size = separator.length();
start = 0;
end = line.indexOf(separator);
while (end != -1) 
    items.add(line.substring(start, end));
...
String[]split(String line, String separator)
split
LinkedList<String> list = new LinkedList<String>();
if (line != null) {
    int start = 0;
    int end = 0;
    int separatorLen = separator.length();
    while ((end = line.indexOf(separator, start)) >= 0) {
        list.add(line.substring(start, end));
        start = end + separatorLen;
...
String[]split(String line, String separator)
split
assertNotNull("line", line);
assertNotNull("separator", separator);
if (line.length() == 0)
    return new String[0];
int separatorLength = separator.length();
List list = new ArrayList();
int previousIndex = 0;
for (int index = line.indexOf(separator); index != -1; index = line.indexOf(separator, previousIndex)) {
...
String[]split(String line, String separator)
Split a string line by separator
if (separator == null || separator.equals(" ")) {
    return line.split("\\s+");
} else {
    String[] strs = line.split(separator);
    List<String> r = new ArrayList<>();
    for (String s : strs) {
        if (!s.isEmpty())
            r.add(s);
...
String[]split(String line, String seperator)
split
if (line == null || seperator == null || seperator.length() == 0)
    return null;
ArrayList<String> list = new ArrayList<String>();
int pos1 = 0;
int pos2;
for (;;) {
    pos2 = line.indexOf(seperator, pos1);
    if (pos2 < 0) {
...
ListSplit(String line, String sptr)
Split
List<String> strs = null;
if (line == null || sptr == null || line.isEmpty())
    return strs;
strs = new ArrayList<String>();
int pos = line.indexOf(sptr);
if (sptr.isEmpty() || pos == -1) {
    strs.add(line);
    return strs;
...
ListsplitArguments(String commandLine, boolean backslashesAreLiteral)
Splits a single string containing multiple command line arguments into separate arguments
List<String> result = null;
if (backslashesAreLiteral) {
    result = splitArgumentsBackslashesAreLiteral(commandLine);
} else {
    result = splitArgumentsBackslashesAreNotLiteral(commandLine);
return result;
ListsplitArgumentsBackslashesAreLiteral(String commandLine)
Splits a single string containing multiple command line arguments into separate arguments
List<String> result = null;
if (commandLine != null) {
    result = new ArrayList<String>();
    char[] c = commandLine.toCharArray();
    boolean readingQuotes = false;
    StringBuilder buffer = new StringBuilder();
    for (int i = 0; i < c.length; i++) {
        char cc = c[i];
...
String[]splitByBrackets(String line)
Extracts a list of all strings contained within brackets.
if (line == null) {
    return (new String[0]);
int start = 0;
int state = 0;
List L = new LinkedList();
for (int i = 0; i < line.length(); i++) {
    char c = line.charAt(i);
...
String[]splitBySeparator(String line, char sep)
Split using a seperator.
String newLine = line;
Vector temp = new Vector();
while (true) {
    int separatorIndex = newLine.indexOf(sep);
    if (separatorIndex == -1) {
        String lastNum = newLine.substring(separatorIndex + 1);
        temp.addElement(lastNum.trim());
        break;
...