Java Utililty Methods String Tokenize

List of utility methods to do String Tokenize

Description

The list of methods to do String Tokenize are organized into topic(s).

Method

String[]tokenizeQuotedStrings(final String aInput, final String aDelimiters)
Tokenizes a given input stream and breaks it into parts on the given delimiters.
if (aInput == null) {
    return null;
final List<String> result = new ArrayList<String>();
String lookback = "";
boolean inQuotedString = false;
final StringTokenizer tokenizer = new StringTokenizer(aInput, aDelimiters, true );
while (tokenizer.hasMoreTokens()) {
...
ArrayListtokenizeQuotes(String f1)
tokenize Quotes
ArrayList<String> fin = new ArrayList();
StringBuilder temp = new StringBuilder();
boolean inQuote = false;
for (int i = 0; i < f1.length(); i++) {
    if (!inQuote)
        if (Character.isWhitespace(f1.charAt(i)))
            continue;
    boolean enter = false;
...
StringtokenizeStatement(String statement)
Given an SQL statement containing "?"
String modifiedSql = statement;
int variableCount = 0;
while (modifiedSql.contains("?")) {
    modifiedSql = modifiedSql.replaceFirst("\\?", "{" + variableCount + "}");
    variableCount++;
return modifiedSql;
ListtokenizeString(final String inputString, final String seperator)
Break apart a string using a tokenizer into a List of String s.
if (inputString == null || inputString.length() < 1) {
    return Collections.emptyList();
final List<String> values = new ArrayList<String>();
values.addAll(Arrays.asList(inputString.split(seperator)));
return Collections.unmodifiableList(values);
String[]tokenizeString(String inString, char delimiter, String enclosures)
Returns an array of tokenized Strings based on the delimiter and enclosures passed in.
ArrayList<String> tokens = new ArrayList<String>();
List<Character> openers = new ArrayList<Character>();
Map<Character, Character> closures = new HashMap<Character, Character>();
if (inString.length() < 1) {
    return new String[0];
if ((enclosures != null) && (enclosures.length() > 0)) {
    for (int indx = 0; indx < enclosures.length(); indx += 2) {
...
StringtokenizeStringArray(String[] array, String token)
this function returns a string that contains all the strings in the array delimited by the token.
if (array.equals(null) || token.equals(null)) {
    return "";
if (array.length > 0 && !array[0].equals(null)) { 
    StringBuffer string_buffer = new StringBuffer(array[0]);
    for (int i = 1; i < array.length; i++) {
        if (!array[i].equals(null) && !array[i].equals("")) {
            string_buffer.append(token);
...
String[]tokenizeStringWithQuotes(String line, String quoteStyle)
Tokenizes string with quotes
ArrayList<String> allTokens = new ArrayList<String>();
String[] tokens = line.split(quoteStyle);
for (int i = 0; i < tokens.length; ++i) {
    if (i % 2 == 0) { 
        String[] sTokens = tokens[i].split("\\s+"); 
        for (int j = 0; j < sTokens.length; allTokens.add(sTokens[j++])) {
    } else {
...
String[]tokenizeToStringArray(String str, String delimiters)
Splits this string into an array using these delimiters.
if (str == null) {
    return null;
String[] tokens = str.split("[" + delimiters + "]");
for (int i = 0; i < tokens.length; i++) {
    tokens[i] = tokens[i].trim();
return tokens;
...
String[]tokenizeToStringArray(String str, String delimiters)
Tokenize the given String into a String array via a StringTokenizer.
return tokenizeToStringArray(str, delimiters, true, true);
String[]tokenizeToStringArray(String str, String delimiters)
tokenize To String Array
return tokenizeToStringArray(str, delimiters, true, true);