Java StringTokenizer(String str, String delim) Constructor

Syntax

StringTokenizer(String str, String delim) constructor from StringTokenizer has the following syntax.

public StringTokenizer(String str,     String delim)

Example

In the following code shows how to use StringTokenizer.StringTokenizer(String str, String delim) constructor.


//w  w w  .j av  a2s. co m
import java.util.StringTokenizer;

public class Main {
   public static void main(String[] args) {

      StringTokenizer st = new StringTokenizer("tutorial/from/java2s.com","/");
      
      // checking next token
      System.out.println("Next token is : " + st.nextToken("/"));
      System.out.println("Next token is : " + st.nextToken("/"));
      System.out.println("Next token is : " + st.nextToken("/"));
   }    
}

The code above generates the following result.