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 how to compare a string using 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 "how to compare a string using String tokenizer" Watch "how to compare a string using String tokenizer" New topic
Author

how to compare a string using String tokenizer

scandalous kk
Greenhorn

Joined: Feb 22, 2009
Posts: 1
hello
my string is
str=" processor : intel pentium "
i am using string tokenizer to print each word from str except the colon
so that my output should look like
processor
intel
pentium
=====
instead of
processor
:
intel
pentium

can anyone help me
thnx in advance

Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

"scandalous kk " welcome to Javaranch
please check your private messages for an important administrative matter. You can check them by clicking the My Private Messages link above.


SCJP, SCWCD.
|Asking Good Questions|
Phuc Bui
Greenhorn

Joined: Feb 19, 2009
Posts: 26
Hi,
First you can use StringTokenizer with colon as delimitation.
You get:
processor
intel pentium

Then use StringTokenizer again with whitespace as delimitation.
You will get
processor
intel
pentium

It's complex, isn't it ?
Or you can do it with your own code, without using StringTokenizer

Cheers,

Phuc Bui
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to compare a string using String tokenizer
 
Similar Threads
64-bit and 32-bit
100% CPU usage on Dual Core PC
Microcontroller????
alternative for Math.cos and Math.sin?
WSAD and Hardware Requirements