This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes A looping question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "A looping question" Watch "A looping question" New topic

A looping question

Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
I encountered a looping question. I have a text file in which there are many tokens separated by ",". Where should I place the "NO RECORD FOUND." code if there is no console input matching with token in text file? It will be displayed even though there is a matching record. I tried to use else block after if block, but still no use because of the 2nd while loop.

Here is the code:

Thanks for help.
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
Suggestion - add a boolean flag (initialized to false before outer loop) and set it to true only when a match is found. Then after the outer loop completes, display the error message if your flag is still false.

Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
Andrew Parker
Ranch Hand

Joined: Nov 12, 2001
Posts: 178
Thanks for your help. It works now.
I agree. Here's the link:
subject: A looping question
Similar Threads
Text File to ArrayList for JTextArea?
breaking up a file that has a delimiter
catching null in a StringTokenizer