Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-29-2009, 07:13 AM
Member
 
Join Date: Jun 2009
Posts: 27
Rep Power: 0
sandeepsai17 is on a distinguished road
Default help needed in saving objects
hi to all,I don't know its is possible or not ,I want to save objects permanently[not in database] until i deleted it.I am keeping my data in a hash table to store sensitive information and i need the same data next time even the application was closed suddenly because of unexpected reasons,of course at last this information was saved in database.If it is possible pls help me.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 06-29-2009, 07:38 AM
angryboy's Avatar
Senior Member
 
Join Date: Jan 2009
Location: Javaland
Posts: 742
Rep Power: 2
angryboy is on a distinguished road
Default
you need to use ObjectStreams to write/read the data to/from a file.
__________________
USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-29-2009, 07:41 AM
Senior Member
 
Join Date: Mar 2009
Posts: 392
Rep Power: 2
Singing Boyo is on a distinguished road
Default
Use FileStreams wrapped with ObjectStreams. Also, you need to ensure that your classes or their superclasses implement Serializable. If an application is closed suddenly, there is not much you can do about it, but other than that, you can write your objects to files
__________________
If the above doesn't make sense to you, ignore it, but remember it - might be useful!
And if you just randomly taught yourself to program, well... you're just like me!
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-29-2009, 08:32 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Originally Posted by Singing Boyo View Post
Use FileStreams wrapped with ObjectStreams. Also, you need to ensure that your classes or their superclasses implement Serializable. If an application is closed suddenly, there is not much you can do about it, but other than that, you can write your objects to files
This is much better.

Actually it's not a good practice to keep lots of data in the memory. Better to write them into a file or a database.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 06-29-2009, 09:23 AM
Member
 
Join Date: Jun 2009
Posts: 27
Rep Power: 0
sandeepsai17 is on a distinguished road
Default
thanks for all for your valuable suggestions.I think serilisation is good solution for me.
Thanks to all.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 06-29-2009, 07:58 PM
makpandian's Avatar
Senior Member
 
Join Date: Dec 2008
Location: Chennai
Posts: 253
Rep Power: 2
makpandian is on a distinguished road
Default
Certainly ,Serialization is the right solution of the problem you had
__________________
Mak
(Living @ Virtual World)
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 06-30-2009, 05:02 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
If you have solved the problem, please mark the thread solved from thread tools. It's really helpful to all members.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
read txt file,with some records, create objects and store objects in tables of a db. stamv Database 1 01-22-2009 05:25 PM
Saving JFrame jralexander New To Java 7 12-03-2008 10:19 PM
Saving changes done through a program xcallmejudasx New To Java 0 12-02-2008 05:53 PM
Saving data...? easyRyder New To Java 8 07-15-2008 04:14 AM
Saving objects to file JavaForums Java Blogs 3 02-02-2008 06:48 PM


All times are GMT +2. The time now is 07:50 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org