返回使用指定定界符指定的CSV值的String数组。
/* * MiscUtils.java * * Copyright (C) 2002-2013 Takis Diakoumis * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 3 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ /* n o w j a v a . c o m 提 供 */ //package com.nowjava; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class Main { /** * Returns a <code>String</code> array of the the CSV value * specified with the specfied delimiter. * * @param csvString the CSV value * @param delim the delimiter used in the CSV value * @return an array of split values */ public static String[] splitSeparatedValues(String csvString, String delim) { StringTokenizer st = new StringTokenizer(csvString, delim); List<String> list = new ArrayList<String>(st.countTokens());