This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes problem in iterating through files. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic

problem in iterating through files.

Ankit Tripathi
Ranch Hand

Joined: Oct 17, 2009
Posts: 186
Hi all,

I have two files Error_Messages_latest_Demo.txt and Error_Rules_Demo.txt.First one contains Error Messages and second one contains Error Rules.Error rules have to be picked from Error_Rules_Demo.txt one-by-one and have to be mapped to Error_Messages_latest_Demo.txt to check whether if there are more than one Error Messages corresponding to one Error Rule.
Below are given the content of both files.


1000,AZK43:GHJXH2:The script failed to complete. See log file for details.
1002,A21:B35:I failed to perform.


1000,^[A-Z0-9_]+:[A-Z0-9_]+:The script failed to complete. See log file for details.$
1002,^[A-Z0-9]+:[A-Z0-9]+:I failed to perform.$

My program is given below.


AZK43:GHJXH2:The script failed to complete. See log file for details.
Error in reading file from specified path String index out of range: -1

It is printing only one line according to matched pattern.after that it is throwing exception.what should I supposed to do?Please reply.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19552

Please UseOneThreadPerQuestion. Let's continue in your previous thread.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: problem in iterating through files.
Similar Threads
read lines after exception
i need to skip lines after exception
how to redirect the linux terminal contents to a textpane
Compare Two Text Files
Iterating through a String.