I am having an issue with an address book because whenever you add a contact then shut the program. The file it is stored in, clears its contents. The objects are written in the file worker class and I think the issue is probably in the FileWorker class. It is written in netbeans so yeah. The link to it is
http://pastebin.com/Mw4c7kFb
You either need to read the file first, or open the file in read/write. new FileOutputStream by default will clear the file it is opening for writing.

Also, you are doing this in a terribly bad way. Rewriting the entire file every time you add a contact is a huge waste of time. File IO is *slloooowww*.

Either:
1) Stream the output to the file (eg, adding one contact writes one contact to the still open output stream)
Or
2) Keep the entire contact list in memory until a save() is called, at which point the in memory data is written to the file
LorenzoNuniz wrote:
Same problem here with the file worker class...What to do?


Hey Mr. Spambot

bye Mr. Spambot (soon..)
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement