Here you can find the source of getTokens(String string)
Parameter | Description |
---|---|
string | The string to parse. |
static protected String[] getTokens(String string)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { /**//from ww w . j av a2 s. c o m * Parse a string into tokens where whitespace is the delimiter. * @param string The string to parse. * @return The array of tokens. */ static protected String[] getTokens(String string) { return getTokens(string, " \t"); } /** * Parse a string into tokens with the specified delimiter. * @param string The string to parse. * @param delim The delimiter * @return The array of tokens. */ static protected String[] getTokens(String string, String delim) { StringTokenizer tokenizer = new StringTokenizer(string, delim); int numTokens = tokenizer.countTokens(); String[] tokens = new String[numTokens]; for (int index = 0; index < numTokens; index++) { tokens[index] = tokenizer.nextToken(); } return tokens; } }