Here you can find the source of tokenizeToStringArray(String str, String delimiters)
Parameter | Description |
---|---|
str | a parameter |
delimiters | a parameter |
public static String[] tokenizeToStringArray(String str, String delimiters)
//package com.java2s; import java.util.*; public class Main { /**//from w w w. j av a 2s.com * * @param str * @param delimiters * @return String[] */ public static String[] tokenizeToStringArray(String str, String delimiters) { return tokenizeToStringArray(str, delimiters, true, true); } /** * * @param str * @param delimiters * @param trimTokens * @param ignoreEmptyTokens * @return String[] */ public static String[] tokenizeToStringArray(String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens) { StringTokenizer st = new StringTokenizer(str, delimiters); List tokens = new ArrayList(); while (st.hasMoreTokens()) { String token = st.nextToken(); if (trimTokens) { token = token.trim(); } if (!ignoreEmptyTokens || token.length() > 0) { tokens.add(token); } } return (String[]) tokens.toArray(new String[tokens.size()]); } }