Java StringTokenizer .nextToken ( String delim)

Syntax

StringTokenizer.nextToken(String delim) has the following syntax.

public String nextToken(String delim)

Example

In the following code shows how to use StringTokenizer.nextToken(String delim) method.


//w  w w  . j a  va2 s  .com

import java.util.StringTokenizer;

public class Main {
   public static void main(String[] args) {
      // with delimeter
      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.