Home » Core Java » util » StringTokenizer

StringTokenizer

Java StringTokenizer Example

Java supports StringTokenizer class, from where we can split a string into tokens. In this example we are going to show the use of StringTokenizer class, as well as some of its basic operations. 1. Syntax of the constructors Depending on our application, we can choose one of the below constructors for StringTokenizer class. StringTokenizer(String str) StringTokenizer(String str, String delim) StringTokenizer(String str, String delim, boolean returnDelims) The possible ...

Read More »

StringTokenizer with specified delimiter

This is an example of how to use a StringTokenizer with a specified delimiter in order to break a String into tokens. We can use the StringTokenizer with a delimiter to break a String, using two methods: In the first method, we use the StringTokenizer(String str, String delim) constructor of StringTokenizer get a string tokenizer for the specified string and ...

Read More »

Tokenize String with StringTokenizer

In this example we shall show you how to tokenize a String with StringTokenizer. The StringTokenizer is used to break a String into tokens. To tokenize a String with StringTokenizer one should perform the following steps: Get a new StringTokenizer for a specified String, using the StringTokenizer(String str) constructor. Get the tokens of the String, using hasMoreTokens() and nextToken() API ...

Read More »

Reverse String with StringTokenizer

With this example we are going to demonstrate how to reverse a String with a StringTokenizer. The StringTokenizer is used to break a String into tokens. In short, to reverse a String with a StringTokenizer you should: Get a new StringTokenizer for a specified String, using the StringTokenizer(String str) constructor. Create a new empty String, that will be the reversed ...

Read More »

StringTokenizer Count Tokens

This is an example of how to use a StringTokenizer to count the tokens of a String. The StringTokenizer is used to break a String into tokens. Using a StringTokenizer to count the tokens of a String implies that you should: Get a new StringTokenizer for a specified String, using the StringTokenizer(String str) constructor. Invoke countTokens() API method of StringTokenizer. ...

Read More »