Here you can find the source of getTokens(String str, String delimiter)
Parameter | Description |
---|---|
str | String to be tokenized |
delimiter | Characters which are delimit tokens |
public static List<String> getTokens(String str, String delimiter)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { /**/*from w ww . ja v a2 s . co m*/ * Return the tokens in a string in a list. This is particularly * helpful if the tokens need to be processed in reverse order. In that case, * a list iterator can be acquired from the list for reverse order traversal. * * @param str String to be tokenized * @param delimiter Characters which are delimit tokens * @return List of string tokens contained in the tokenized string */ public static List<String> getTokens(String str, String delimiter) { ArrayList<String> l = new ArrayList<String>(); StringTokenizer tokens = new StringTokenizer(str, delimiter); while (tokens.hasMoreTokens()) { l.add(tokens.nextToken()); } return l; } }