12 8 5 32
4 tokens, delimited by spaces.
Tokens can be separated by more than one delimiter. There are several spaces separating the tokens in the example. Here are some methods of the class:
The countTokens() method starts with the total number of
tokens the String has been broken into.
Each time nextToken()countTokens()
import java.io.*;
import java.util.*;
public class TokenTester
{
  public static void main ( String[] args ) throws IOException
  {
    BufferedReader stdin = 
      new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Enter a string:");
    String data = stdin.readLine();   
    
    StringTokenizer tok = new StringTokenizer( data );
    while ( tok.hasMoreTokens() )
      System.out.println( tok.nextToken() );
  }
}