import java.util.StringTokenizer; /** * This class is an extension of StringTokenizer to keep track of * the last token retrieved by the nextToken method. This `last token' * can then be accessed by the method GetCurrentToken without moving * the token stream forward. The only flavour of constructor that is * supported is one that uses the default delimiters (which are whitespace * as defined by the isSpace method in the class Character). *

* source * @version 1.0 18 January 1998 * @author Robert E. Webber * @see MyStringTokenizer#nextToken * @see MyStringTokenizer#GetCurrentToken */ public class MyStringTokenizer extends StringTokenizer { private String TheCurrentToken; /** * This constructor simply invokes the corresponding * constructor in the class StringTokenizer. * @param String is the String to be tokenized. */ public MyStringTokenizer (String TheString) { super(TheString); } /** * This method removes the next symbol from the string being * tokenized. White space is ignored. * @return a String corresponding to the next symbol in the token stream. */ public String nextToken() { return TheCurrentToken = super.nextToken(); } /** * Gives access to the last token retrieved. * @return the last String fetched by nextToken from this token stream. */ public String GetCurrentToken() { return TheCurrentToken; } }