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

Read and search for text in a file

Hari MohanSingh
Greenhorn

Joined: Dec 19, 2010
Posts: 4
Hi,
I have a file like this
ABCD 123 blah blah
int varx;
string varb;

xyz = varb;

blah blah

What I need to do:
search in the file for xyz and find varb and then find
string varb;
and extract what it is a string.

so the definition of varb is before it is used, so I need to find if it is used and then find what it is defined as.

How do I do this? The file will be Unix formatted but stored locally on a DOS machine.
Thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38363
    
  23
Do you know how to find a String inside a String?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Read and search for text in a file