Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

How do I use ObjectOutputStream with my objects?
Do I have to implement the serializable interface?
Is the default implementation of the serializable interface enough?





Report this thread to moderator Post Follow-up to this message
Old Post
Kiran Kumar Kamineni
09-27-04 08:57 AM


Re: How do I use ObjectOutputStream with my objects?
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.

Report this thread to moderator Post Follow-up to this message
Old Post
Stefan Schulz
09-27-04 08:57 AM


Re: How do I use ObjectOutputStream with my objects?
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.


Report this thread to moderator Post Follow-up to this message
Old Post
Jacob
09-27-04 02:07 PM


Re: How do I use ObjectOutputStream with my objects?
"Kiran Kumar Kamineni" <kkumar@hp.com> wrote in message news:<4157ab8e$1@usenet01.boi.hp.co
m>...
> 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

Report this thread to moderator Post Follow-up to this message
Old Post
Yakov
09-28-04 02:02 AM


Re: How do I use ObjectOutputStream with my objects?
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.


Report this thread to moderator Post Follow-up to this message
Old Post
Alexey
12-13-04 01:57 AM


Re: How do I use ObjectOutputStream with my objects?
Good point about serialization, Jacob.

To overcome the pitfalls of ObjectOutputStream, you may want to look at
XMLEncoder in the java.beans package.
http://java.sun.com/j2se/1.4.2/docs...XMLEncoder.html


Report this thread to moderator Post Follow-up to this message
Old Post
Jon Caldwell
02-24-05 01:59 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:35 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.