This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes String tokenizer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String tokenizer" Watch "String tokenizer" New topic
Author

String tokenizer

Kalpesh Soni
Ranch Hand

Joined: Jan 02, 2001
Posts: 312

output
------
C:\jdk\bin\java.exe TokenTest
Working Directory - D:\ksoni\javaTests\
Class Path - .;c:\jdk\lib;c:\j2sdkee1.3\lib\j2ee.jar;c:\KawaEnt5.0\kawaclasses.zip;c:\jdk\lib\tools.jar;c:\jdk\jre\lib\rt.jar;c:\jdk\jre\lib\i18n.jar
1[1003]
2[$]
3[$]
4[03]
5[$]
6[$]
7[$]
8[$]
9[suggestion1]

1[1003]
2[03]
3[suggestion1]
Process Exit...
--------
question
--------
how do i get an array of tokens ?
i do not want the $ sign
the token may not be there !in that case array element should be null
and see the delim "$a" , it seems a is ignored !
what if i have delim of two chars or more ??
--kalpesh


Test 094, IBM WID 6.0 cert
SCJP 1.2
SCBCD 1.3 Beta
SCWCD 1.4 Beta
SCMAD Beta
SCDJWS Beta

KS
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Kalpesh,
In your first example the letter a is not being ignored. You don't have any 'a' characters in your original string (temp). The characters inside the delimiter string are considered separately and not in a group (i.e., treated as an array of chars instead of string).
StringTokenizer has not been implemented to return empty tokens. If you require that then you must write your own tokenizer that does that.
If you want an array of tokens you can just do the following:

Regards,
Manfred.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String tokenizer
 
Similar Threads
String tokenizer
Help
StringTokenizer
how to cast array of Object
how to avoid null pointer exception