File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes individual strings from a line.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "individual strings from a line...." Watch "individual strings from a line...." New topic

individual strings from a line....

Brandi Love
Ranch Hand

Joined: Sep 19, 2003
Posts: 133
How would I write a loop so that it would use a tokenizer to read each individual string from a line in a text file? I want it to be able to return each induvidual word to test it for a certain condition, and then break out of the loop when the line is finished.
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
One of the nice features of the JavaRanch forums is that they can be searched. And believe me, many of those past conversations are full of good information. (This obviously excludes all chatter in MO and MD.)
I just did a quick search on FileReader and stumbled across an old thread in which Corey McGlone posted the example code I've often seen and used to read in a text file line-by-line. I'd bet you'll be able to modify his example to do the processing (and breaking) as you want it.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: individual strings from a line....
It's not a secret anymore!