Java Utililty Methods String Split by Quote

List of utility methods to do String Split by Quote

Description

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

Method

String[]splitQuoted(String input, Character split)
Splits a string and returns the parts as array.
List<String> parts = new ArrayList<>();
splitQuoted(input, split, parts);
String[] result = new String[parts.size()];
return parts.toArray(result);
ListsplitQuoted(String str, char delimiter)
split Quoted
return splitQuoted(str, delimiter, false);
CollectionsplitQuotedEscape(String src)
split Quoted Escape
List<String> results = new ArrayList<>();
StringBuilder sb = new StringBuilder();
boolean escaped = false;
for (char ch : src.toCharArray()) {
    if (ch == ' ' && !escaped) {
        String s = sb.toString();
        if (!s.isEmpty()) {
            results.add(s);
...
ListsplitQuotedStr(String str, char delimiter, char quote, boolean trim)
split Quoted Str
int startPos = 0;
boolean insideQuotation = false;
List<String> result = new ArrayList<String>();
for (int i = 0; i < str.length(); i++) {
    char c = str.charAt(i);
    if (c == quote) {
        insideQuotation = !insideQuotation;
    if (!insideQuotation && c == delimiter) {
        String subStr = str.substring(startPos, i);
        if (trim) {
            subStr = subStr.trim();
        result.add(subStr);
        startPos = i + 1;
        continue;
if (startPos < str.length()) {
    String subStr = str.substring(startPos, str.length());
    if (trim) {
        subStr = subStr.trim();
    result.add(subStr);
return result;
ListsplitQuotedString(String str)
Splits a string based on spaces, grouping atoms if they are inside non escaped double quotes.
List<String> strings = new ArrayList<String>();
int level = 0;
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
    char c = str.charAt(i);
    if (c == '"') {
        if (i == 0 || str.charAt(i - 1) == ' ') {
            level++;
...
ListsplitQuotedString(String str)
Splits a string based on spaces, grouping atoms if they are inside non escaped double quotes.
List<String> strings = new ArrayList<String>();
boolean inQuotes = false;
boolean quoteStateChange = false;
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
    char c = str.charAt(i);
    quoteStateChange = false;
    if (c == '"' && (i == 0 || str.charAt(i - 1) != '\\')) {
...
String[]splitQuotedTokens(String str)
splits space separated tokens respecting quotes (either " or ' )
List<String> bits = new ArrayList<String>();
char quote = ' ';
boolean escape = false;
boolean bit_contains_quotes = false;
String bit = "";
char[] chars = str.toCharArray();
for (int i = 0; i < chars.length; i++) {
    char c = chars[i];
...
String[]splitSafeQuote(String input, char separator)
Splits the input safely honoring if values is enclosed in quotes.
return splitSafeQuote(input, separator, true);
ListsplitShifted(int[] shiftedQuoteString)
split Shifted
List out = new ArrayList();
int sstart = 0;
for (int finger = 0, len = shiftedQuoteString.length; finger <= len; ++finger) {
    if (finger == len || shiftedQuoteString[finger] == ',') {
        int slen = finger - sstart;
        int tstart;
        int tlen = -1;
        for (tstart = sstart; tstart <= finger; ++tstart) {
...
String[]splitStringWithQuotes(String in)
split String With Quotes
char[] chars = in.trim().toCharArray();
int state = 0;
ArrayList<String> wordList = new ArrayList<String>();
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < chars.length; i++) {
    switch (state) {
    case 0:
        if (chars[i] == '\t' || chars[i] == ' ') {
...