List of utility methods to do String Split by Line
String[] | fastSplit(final String line, final char c) Splits a string using a character. int nextSplit = line.indexOf(c); if (nextSplit < 0) { return new String[] { line }; final List<String> splits = new ArrayList<String>(); int lastSplit = -1; while (nextSplit > 0) { splits.add(line.substring(lastSplit + 1, nextSplit)); ... |
String[] | split(String aLine, char delimiter, char beginQuoteChar, char endQuoteChar, boolean retainQuotes, boolean trimTokens) Splits the specified delimited String into tokens, supporting quoted tokens so that quoted strings themselves won't be tokenized. String line = clean(aLine); if (line == null) { return null; List<String> tokens = new ArrayList<String>(); StringBuilder sb = new StringBuilder(); boolean inQuotes = false; for (int i = 0; i < line.length(); i++) { ... |
String[] | split(String line) split return split(line, DEFAULT_DELIMITER_CHAR);
|
String[] | split(String line) This method splits a single CSV line into junks of String . List<String> results = new ArrayList<>(); StringBuffer buffer = new StringBuffer(line); while (buffer.length() > 0) { if (buffer.indexOf("\"") == 0) { int endIndex = buffer.indexOf("\"", 1); String result = buffer.substring(1, endIndex); results.add(result); buffer.delete(0, endIndex + 2); ... |
String[] | split(String line) split return split(line, DEFAULT_DELIMITER_CHAR);
|
String[] | split(String line) split List<String> args = new ArrayList<String>(); boolean quote = false; StringBuffer arg = new StringBuffer(); for (int i = 0; i < line.length(); i++) { char c = line.charAt(i); if (c == '"') { quote = !quote; continue; ... |
String[] | split(String line, char delimiter) Splits the row into separate cells based on the delimiter character. return split(line, "" + delimiter); |
ArrayList | split(String line, char delimiter) split int prevPos = 0; ArrayList<String> tokens = new ArrayList<String>(); final int len = line.length(); for (int index = 0; index < len; ++index) { if (line.charAt(index) == delimiter) { tokens.add(line.substring(prevPos, index)); prevPos = index + 1; tokens.add(line.substring(prevPos, len)); return tokens; |
List | split(String line, String delimiter) split String[] elements = line.split(delimiter);
return Arrays.asList(elements);
|
String[] | split(String line, String regex) split List<String> strings = new ArrayList<String>(); String part = ""; for (int i = 0; i < line.length() - (regex.length() - 1); i++) { if (line.substring(i, i + regex.length()).equalsIgnoreCase(regex)) { strings.add(part); part = ""; i = i + regex.length() - 1; } else { ... |