This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to compare a string using String tokenizer

 
scandalous kk
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
Phuc Bui
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic