File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Doubts in the operation of StringTokenizer Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Doubts in the operation of StringTokenizer" Watch "Doubts in the operation of StringTokenizer" New topic
Author

Doubts in the operation of StringTokenizer

dinesh Venkatesan
Ranch Hand

Joined: Oct 12, 2006
Posts: 134
Hi All,

Please look at the following code:

import java.util.*;

public class Tester {
public static void main(String[] args) {
StringTokenizer st = new StringTokenizer("CustomeCare.$ser$",".$ser$");
while(st.hasMoreTokens()){
System.out.println(st.nextToken());
}
}
}

I am getting the output as:

Cu
tom
Ca

Does the "$"symbol has anything to do with the operation of tokenizing the String? Please explain.

Thanks in Advance!!!
dinesh.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24081
    
  15

The second argument to StringTokenizer's constructor is a list of characters that are token separators. It's not taken as a sequence of characters together -- each individual character is a separator all by itself.

Don't use StringTokenizer -- use the String.split() method.


[Jess in Action][AskingGoodQuestions]
dinesh Venkatesan
Ranch Hand

Joined: Oct 12, 2006
Posts: 134
Thanks for clarification!
Thank you very much!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubts in the operation of StringTokenizer
 
Similar Threads
Alternative to string tokenzier
Load on startup
serialization
retrieving value from a text box
Did you see this ?StringTokenizer