How to quickly find if a word exists or not in a text file?

W

www

Hi,

My Java needs to check a log file to see if things are correct. If there
is a word, "successfully", then it is correct. I hate to read in each
line, parse it into tokens, and check each token. Is there a better way
to do it?

Thank you.
 
D

Danno

Hi,

My Java needs to check a log file to see if things are correct. If there
is a word, "successfully", then it is correct. I hate to read in each
line, parse it into tokens, and check each token. Is there a better way
to do it?

Thank you.

If you use log4j you can create your own intercepting appender that
alerts you when the "successfully" message is placed into the log file.
 
A

Alex Hunsley

www said:
Hi,

My Java needs to check a log file to see if things are correct. If there
is a word, "successfully", then it is correct. I hate to read in each
line, parse it into tokens, and check each token. Is there a better way
to do it?

Break into tokens? How about using String.indexOf() instead?
 
D

Daniel Pitts

Hi,

My Java needs to check a log file to see if things are correct. If there
is a word, "successfully", then it is correct. I hate to read in each
line, parse it into tokens, and check each token. Is there a better way
to do it?

Thank you.
How about using indexOf or regex? Better yet, is there any way the
log-writting process can indicate success/failure through another more
direct means? Such as return code?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top