Home > Archive > Java Help > February 2005 > How do I use ObjectOutputStream with my objects?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How do I use ObjectOutputStream with my objects?
|
|
| Kiran Kumar Kamineni 2004-09-27, 3:57 am |
| Do I have to implement the serializable interface?
Is the default implementation of the serializable interface enough?
| |
| Stefan Schulz 2004-09-27, 3:57 am |
| On Mon, 27 Sep 2004 11:23:13 +0530, Kiran Kumar Kamineni <kkumar@hp.com>
wrote:
> Do I have to implement the serializable interface?
> Is the default implementation of the serializable interface enough?
That depends on what your Objects are. If they consist only of primitives
and Serializable
Objects, yes. If not, no.
--
Whom the gods wish to destroy they first call promising.
| |
|
| Kiran Kumar Kamineni wrote:
> Do I have to implement the serializable interface?
> Is the default implementation of the serializable interface enough?
As a side note: Don't use the Object OutputStream unless you know
what you are doing. It is not suited for making objects persistent
as it doesn't handle versioning very well (store a class instance,
change the class definition slightly, and your stored object is
forever beyond reach).
The ability to serialize objects was invented to handle object
transfer over a network, but is widely misused as a persistence
technology because it makes object save/retrieve so (apparently)
simple.
To store objects, use text files a'la properties files, XML
or something similar. It takes a bit more effort as it needs
custom save/load methods.
| |
|
| "Kiran Kumar Kamineni" <kkumar@hp.com> wrote in message news:<4157ab8e$1@usenet01.boi.hp.com>...
> Do I have to implement the serializable interface?
> Is the default implementation of the serializable interface enough?
Read my article on the subject:
http://www.sys-con.com/story/?storyid=44199
Regards,
Yakov
| |
| Alexey 2004-12-12, 8:57 pm |
| Jacob wrote:
> Kiran Kumar Kamineni wrote:
>
>
> As a side note: Don't use the Object OutputStream unless you know
> what you are doing. It is not suited for making objects persistent
> as it doesn't handle versioning very well (store a class instance,
> change the class definition slightly, and your stored object is
> forever beyond reach).
>
> The ability to serialize objects was invented to handle object
> transfer over a network, but is widely misused as a persistence
> technology because it makes object save/retrieve so (apparently)
> simple.
>
> To store objects, use text files a'la properties files, XML
> or something similar. It takes a bit more effort as it needs
> custom save/load methods.
Not necessarily. Consider using XMLEncoder and XMLDecoder (java.beans
package) for easy automatic XML persistance. Still doesn't solve every
possible case with complex objects, but works quite well nevertheless
and handles versioning very well.
| |
|
|
|
|
|