aspose file tools*
The moose likes Beginning Java and the fly likes finding a particular string in string type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "finding a particular string in string type" Watch "finding a particular string in string type" New topic
Author

finding a particular string in string type

kundan varma
Ranch Hand

Joined: Mar 08, 2004
Posts: 322
Hi All,
I need to find whether a particular string like "kundan" exist in a line or not. What is the best way to solve this in java?
Can somebody give a example.
Thanks and regards,
kundan


SCJP1.4,SCBCD,SCEA,CNA
Failures are practice shoots for success.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3169
    
  10
String.indexOf()


Joanne
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36508
    
  16
Have you never tried the contains method in String? It only works in J5 and 6, however.
Rakesh Kumar
Ranch Hand

Joined: May 30, 2006
Posts: 63
welcome to javaranch discussion boards

let 's' be the the string coressponding theline,then
s.indexOf("kundan") will give the index of 1st occurence of the string"kundan".

cheers
sujith
Parambir Singh
Ranch Hand

Joined: Sep 05, 2004
Posts: 40

And if "kundan" is not present, it will return -1.


SCJP, SCMAD
http://parambir.me
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Advanced? I think not. Moving to Java in General (Beginner).


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: finding a particular string in string type
 
Similar Threads
Passed SCEA part 2/3 with 70
using plus inside StringBuffer
using plus inside StringBuffer
Accessing session object from getConnection method
Why HashSet is adding duplicates even if I get same hashcode for two obects & passes true fromequals