Thread: Issue
View Single Post
  #12 (permalink)  
Old 11-28-2009, 02:40 AM
pbrockway2 pbrockway2 is offline
Senior Member
 
Join Date: Feb 2009
Posts: 632
Rep Power: 2
pbrockway2 is on a distinguished road
Default
In that case the contents of your text file actually contains

Code:
1
Phrases@92dcdb
and not what you posted in reply #7. This could have happened because your code called save() previously and overwrote the data file.

To deal with the NoSuchElementException restore the data file and use the debugging code as posted. It is designed to give quite a few lines of output, not one.

[Edit]

It would be a good idea to separate files for input and output in order to avoid this sort of confusion.

And to add a line of debugging code to the save method:

Code:
public void save(String pirateTxt) throws IOException{
    // etc
    outfile.println(phrase.size());
    for (Phrases p:phrase) {
        System.out.println("About to write the line " + p.toString() + " into the data file");
        outfile.println(p.toString()); 
    }
    outfile.close();
}

Last edited by pbrockway2; 11-28-2009 at 02:45 AM.
Reply With Quote