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

ListsplitLines(String text)
split Lines
if (text == null)
    return null;
List<String> lines = new ArrayList<String>();
int TEXT = 0;
int CR = 1;
int LF = 2;
int mode = TEXT;
StringBuilder builder = new StringBuilder();
...
ListsplitLines(String text)
Split the string in lines; separate by CR, LF or CRLF.
List<String> list = new ArrayList<>();
if (text != null) {
    String lines[] = text.split("\r?\n|\r");
    list.addAll(Arrays.asList(lines));
return list;
ArrayListsplitLogLine(final String logLine)
split Log Line
String[] splitString = logLine.split(LOG_LINE_SEPARATOR);
ArrayList<String> result = new ArrayList<>();
for (String split : splitString) {
    if (!LOG_LINE_SEPARATOR.equals(split) && !EMTPY_STRING.equals(split)) {
        result.add(split);
return result;
...
ListsplitMultiline(String text, boolean trimLines)
split Multiline
final List<String> result = new ArrayList<>();
final String[] lines = text.split("\\r\\n|\\n|\\r");
for (String line : lines) {
    result.add(trimLines ? line.trim() : line);
return result;
String[]splitNewLines(final String input)
split New Lines
int length = input.length();
List resultList = new ArrayList();
int start = 0;
char last = 0;
for (int i = 0; i < length; i++) {
    char ch = input.charAt(i);
    if (ch == '\n') {
        if (last != '\r') {
...
ListsplitNextWord(String line)
split Next Word
line = line.trim();
if (line.length() == 0) {
    return null;
StringBuilder builder = new StringBuilder();
boolean quoted = line.charAt(0) == '"';
int start = quoted ? 1 : 0;
int end = start;
...
String[]splitString(String line)
Splits a String into a String[].
int len = line.length();
int wordCount = 0;
int pos = 0;
while (pos < len) {
    while (pos < len && line.charAt(pos) <= ' ')
        pos++;
    int start = pos;
    while (pos < len && line.charAt(pos) > ' ')
...
ListsplitStringPerWord(String string, int wordsPerLine)
split String Per Word
String[] words = string.split(" ");
List<String> lines = new ArrayList<String>();
for (int lineCount = 0; lineCount < Math.ceil((float) words.length / (float) wordsPerLine); lineCount++) {
    String stringInLine = "";
    for (int i = lineCount * wordsPerLine; i < Math.min(wordsPerLine + lineCount * wordsPerLine,
            words.length); i++) {
        stringInLine += words[i] + " ";
    lines.add(stringInLine.trim());
return lines;
String[]splitter(String line, char delimeter)
splitter
List<String> strs = new ArrayList<>();
int idxOfNextWord = 0;
for (int i = 0; i < line.length(); i++) {
    if (line.charAt(i) == delimeter) {
        strs.add(line.substring(idxOfNextWord, i));
        idxOfNextWord = i + 1;
    if (i == line.length() - 1 && line.charAt(i) == delimeter) {
...
ListsplitToLines(CharSequence str)
split To Lines
int pre = 0;
int length = str.length();
ArrayList<CharSequence> lines = new ArrayList<CharSequence>(128);
for (int i = 0; i < length; i++) {
    char c = str.charAt(i);
    if (c == '\n') {
        lines.add(str.subSequence(pre, i));
        pre = i + 1;
...