aspose file tools
The moose likes Beginning Java and the fly likes How to find a word in a text file? (2) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "How to find a word in a text file? (2)" Watch "How to find a word in a text file? (2)" New topic
Author

How to find a word in a text file? (2)

Ekrem Altintas
Greenhorn

Joined: Dec 20, 2005
Posts: 14
hellohowareyouhellohowareyou

For example, I want to find "hello" words in the text above. There is not spaces in this text.What can I do?
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2341
String s = ...

int index = s.indexOf("...");
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Note that there is also an indexOf(str, fromIndex).

So if the first occurrence is at index 7, for example, then you could find the next occurrence using indexOf("...", 8).


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Ekrem Altintas
Greenhorn

Joined: Dec 20, 2005
Posts: 14
Tahnks. It has worked
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to find a word in a text file? (2)
 
Similar Threads
jdbc text drivers
File constructor
Difference between Abstract Class and Interface, Which scenarios we are using both?
JTextPane vs AWT TextArea
Trying to extract text portion of select statement entry