Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

individual strings from a line....

 
Brandi Love
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic