Here you can find the source of tokenizeStringWithQuotes(String line, String quoteStyle)
public static String[] tokenizeStringWithQuotes(String line, String quoteStyle)
//package com.java2s; /******************************************************************************* * Copyright (c) 2004, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from ww w .j a v a2s .c om * IBM - Initial API and implementation *******************************************************************************/ import java.util.ArrayList; public class Main { /** * Tokenizes string with quotes */ public static String[] tokenizeStringWithQuotes(String line, String quoteStyle) { ArrayList<String> allTokens = new ArrayList<String>(); String[] tokens = line.split(quoteStyle); for (int i = 0; i < tokens.length; ++i) { if (i % 2 == 0) { // even tokens need further tokenization String[] sTokens = tokens[i].split("\\s+"); //$NON-NLS-1$ for (int j = 0; j < sTokens.length; allTokens .add(sTokens[j++])) { } } else { allTokens.add(tokens[i]); } } return allTokens.toArray(new String[allTokens.size()]); } }