/******************************************************************************
 * Example of String tokenization.  
 * Convert a String into an Array of words 
 ******************************************************************************/
import java.util.StringTokenizer;

public class stringToken
{
    public static void main (String[] args) 
    {
        int next = 0;

        //---- String tokenization ---------------------------------------

        String text = "the quick brown fox jumped over the lazy dog";                   
        System.out.println(text + '\n');

        StringTokenizer st;                         //declare a string tokenizer 
    
        st = new StringTokenizer(text, " ");        //tokenize on a space

        int numWords = st.countTokens();            //number of tokens  

        System.out.println("Number of words: " + numWords );

        String[ ] words = new String[numWords];     //new array of size numWords

    
        while (st.hasMoreTokens() )                 //are there more words?
        {
            String word = st.nextToken();           //next word

            System.out.println(word);               //print the word

            words[next++] = word;                   //save word in the array
        }
    }
}