aspose file tools*
The moose likes I/O and Streams and the fly likes Reading consecutive text file lines using scanner and actionListener event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Reading consecutive text file lines using scanner and actionListener event" Watch "Reading consecutive text file lines using scanner and actionListener event" New topic
Author

Reading consecutive text file lines using scanner and actionListener event

dave t.gibson
Greenhorn

Joined: Apr 27, 2011
Posts: 1

I would be grateful if someone can come up with some suggestions please, ( I am currently revising for an exam).I have been having trouble reading consecutive lines from a text file using scanner through an actionListener event (button press or a mouseListener event, mousePressed); so that each button press reads the first line of text and the next button press reads the second line and so on. I cannot use a collection to store the text first.
I have put together a small example of what i am trying. I can read the whole text file no problem and i can read the first line of text without a problem. I have considered using some form of count comparison but cannot get that to work either. There are various commented out statements included as part of my attempts. Thanks



Please ignore my request I have finally solved the problem. By declaring the scanner object as an instance variable and instantiating it in the constructor inside a try catch block and removing the matching code from the button watcher, it all works.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading consecutive text file lines using scanner and actionListener event