String tokenizer splits the string based on the tokens (delimiter).
Class Name: multiTokenExample.java
package com.token;
import java.util.StringTokenizer;
class multiTokenExample {
public static void main(String args[]) {
String input = "This#is%my&world";
StringTokenizer split = new StringTokenizer(input, "#&%");
while (split.hasMoreTokens()) {
System.out.println(split.nextToken());
}
}
}
OUTPUT:
This
is
my
world
No comments:
Post a Comment