Results 1 to 7 of 7
  1. #1
    sandeepsai17 is offline Member
    Join Date
    Jun 2009
    Posts
    30
    Rep Power
    0

    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.

  2. #2
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    you need to use ObjectStreams to write/read the data to/from a file.
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

  3. #3
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    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!

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote 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.

  5. #5
    sandeepsai17 is offline Member
    Join Date
    Jun 2009
    Posts
    30
    Rep Power
    0

    Default

    thanks for all for your valuable suggestions.I think serilisation is good solution for me.
    Thanks to all.

  6. #6
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    450
    Rep Power
    6

    Default

    Certainly ,Serialization is the right solution of the problem you had
    Mak
    (Living @ Virtual World)

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Replies: 1
    Last Post: 01-22-2009, 05:25 PM
  2. Saving JFrame
    By jralexander in forum New To Java
    Replies: 7
    Last Post: 12-03-2008, 10:19 PM
  3. Saving changes done through a program
    By xcallmejudasx in forum New To Java
    Replies: 0
    Last Post: 12-02-2008, 05:53 PM
  4. Saving data...?
    By easyRyder in forum New To Java
    Replies: 8
    Last Post: 07-15-2008, 04:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •