/*** minimal StringTokenizer implementation.*/class StringTokenizer{ // the string to be tokenized private final String str; // the delimiter private final String delim; // the token index private final int index; // token buffer private final ArrayList<String> tokens; /** * Creates a new minimal StringTokenizer * @param str * @param delim */ public StringTokenizer(String str, String delim) { this.str = str; this.delim = delim; this.tokens = new ArrayList<String>(); this.index = 0; // being tokenizing tokenize(); } /** * Quantizes the String into pieces by separating them via the defined * delimiter */ private void tokenize() { int offset = 0; int end = 0; String sub = null; while( end != -1) { end = this.str.indexOf(this.delim, offset); if(end == -1) { sub = this.str.substring(offset); this.tokens.add(sub); break; } else { sub = this.str.substring(offset, end); this.tokens.add(sub); } offset = end + 1; } } /** * Returns if there more tokens. * @return true if there are more tokens */ public boolean hasMoreTokens() { return this.tokens.size() > 0; } /** * returns the next token * @return */ public String nextToken() { return this.tokens.remove(index); }}