File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Android Security Essentials Live Lessons this week in the Android 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to compare a string using String tokenizer
 
Similar Threads
64-bit and 32-bit
alternative for Math.cos and Math.sin?
Microcontroller????
100% CPU usage on Dual Core PC
WSAD and Hardware Requirements