This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
hi, I want to ask what's the problem with my program..
My program is about stacks, there's no error in it, but my problem is, our requirement is do all operations in stacks and then, even if you close the program, the next time you will open it, the previous data should still be displayed..
I used the filewriter and filereader, but every time I close it, then open it again, the previous data doesn't appear..
thanks.. here's my program.
Champ, I didn't test your program, but, at a first glance, the first thing that comes to my mind is, on line 41, when you are saving the content, try invoking out.flush() before invoking out.close() and let's see if it works.
Andrew Monkhouse wrote:When do you think your readMe method is called? Perhaps you could verify that (some simple debug statements (System.out.println will do) will verify if it is called at the right time (or ever)).
I did what you said,.. the readMe method is called whenever i click a button..
then the saveMe method is called after I supplied what is needed.. I put a message dialog box to inform whenever these two methods are called, so it's a sure that they were called,. cause when i run the program, just like I said, they appeared before and after...
author and jackaroo
Andrew Monkhouse wrote:Looking at the "readMe" method - how many lines are in the file written to disk? How many lines are you trying to read?
in the notepad, there's only one line..
Each pair of questions I asked is related to a different problem. But just on this one question, go back and look at your readMe method. Where is your call to "nextLine"? For that matter, where is the "id" variable defined? Where is your loop? Again - you might want to put debug statements in your method and in your loop and see what is being called when, and what the results are.
I left out some more important questions too - what are the constructors for the Scanner class? Is there a better constructor for you to use?
I know that this seems like we are only inching our way to a solution, but trust me - if you can get answers to these questions, you will be a long way to solving this (and future) problems yourself.