Here you can find the source of tokenize(String str, char delim)
public static List<String> tokenize(String str, char delim)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static List<String> tokenize(String str, char delim) { ArrayList<String> result = new ArrayList<String>(); StringBuilder current = new StringBuilder(); boolean escaped = false; for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c == delim) { if (escaped) { current.append(c);// w w w . j av a 2s . co m escaped = false; } else { escaped = true; } } else { if (escaped && current.length() > 0) { result.add(current.toString()); current.setLength(0); escaped = false; } current.append(c); } } if (current.length() > 0) { result.add(current.toString()); } return result; } /** * Return a stringified version of the array. * @param array the array * @param delim the delimiter to use between array components * @return the string form of the array */ public static String toString(final Object[] array, final String delim) { return toString(array, delim, true); } /** * Return a stringified version of the array. * @param array the array * @param delim the delimiter to use between array components * @return the string form of the array */ public static String toString(final Object[] array, final String delim, boolean includeBrackets) { if (array == null) { return ""; //$NON-NLS-1$ } final StringBuffer sb = new StringBuffer(); if (includeBrackets) { sb.append('['); } for (int i = 0; i < array.length; ++i) { if (i != 0) { sb.append(delim); } sb.append(array[i]); } if (includeBrackets) { sb.append(']'); } return sb.toString(); } /** * Return a stringified version of the array, using a ',' as a delimiter * @param array the array * @return the string form of the array * @see #toString(Object[], String) */ public static String toString(final Object[] array) { return toString(array, ",", true); //$NON-NLS-1$ } }