StringTokenizer Tokenizing String

StringTokenizer Tokenizing String



The following is another program on "StringTokenizer Tokenizing String" that takes a group of delimiters supplied explicitly.

StringTokenizer Tokenizing String

String str1 = "Awake@arise*stop/notmuntil@goal*reach";
StringTokenizer st1 = new StringTokenizer(str1, "@,m,*,/");

The delimiters in the string str1 are @, m, * and / and these are supplied as second parameter in the constructor. Now, the StringTokenizer tokenizes as per these delimiters supplied.

A similar class exist that tokenizes a stream of data – StreamTokenizer – Tokenizing a Stream.

2 thoughts on “StringTokenizer Tokenizing String

Leave a Reply

Your email address will not be published. Required fields are marked *