• Post Reply Bookmark Topic Watch Topic
  • New Topic

Save User define class Object in to File

 
Deva
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here I have a class "Car". This contains several static variables & other primitives.
When i'm running my app call "CollectCars",i want save a Car object (ex: honda_civic) in to a File (Say as Honda_Civic.txt) and i want load this saved object "honda_civic" back in to another application by loading that Honda_Civic.txt.

I thought this may possible when i use ObjectOutputStream & ObjectInputStream (by using readObject(), writeObject()). but it is not work.

i just need to save the current car object in to file system file & load it back as a car object by another program.

can any one suggest a solution.
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Deva. We don't ask much of our participants, just that they be nice and that their displayed names consist of a first and last name and not be obviously fake. Please adjust your displayed name to meet the
JavaRanch Naming Policy. You can do that here.
Now, as for your question, you need to help us help you. You say you tried to use an ObjectIn(Out)putStream and it didn't work. What didn't work? Did it throw an exception? What was the exception? What did your code look like (WARNING: submitting large amounts of code (greater than 10-20 lines) will practically guarantee you no help!). Have you looked at the Java Tutorial for examples of how to use Object Serialization?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!