Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

Serializable interface and Double-Linked List

Thread view: 
Bulkan@gmail.com - 09 Jan 2006 07:18 GMT
Hi all,

I have this double linked list that. The nodes only have a
String as an instance variable.

What i want to be able to do is Serialize the double linked
list (the one with the methods addNode,deleteNode etc...)
and all the nodes inside the double linked list (so starting
from head  traverse the entire list and write out each node
in the list), then i wont to somehow read all the nodes into
the list.

The only way to this i think is to implement the following
methods, but havent done this before, so any help/example
will be appreciated.

private void writeObject(java.io.ObjectOutputStream out)
throws IOException
{
}

private void readObject(java.io.ObjectInputStream in) throws
IOException, ClassNotFoundException
{
}
Chris Smith - 09 Jan 2006 07:28 GMT
> What i want to be able to do is Serialize the double linked
> list (the one with the methods addNode,deleteNode etc...)
> and all the nodes inside the double linked list (so starting
> from head  traverse the entire list and write out each node
> in the list), then i wont to somehow read all the nodes into
> the list.

Easy.  Have your node class implement Serializable, and you're done.  Or
easier yet, abandon your NIH-syndrome doubly linked list class and use
java.util.ArrayList, which already implements Serializable.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

placid - 09 Jan 2006 07:35 GMT
I already have, but when i write out the double linked list, and then
read it back in the only node that is written is the head node, the
rest is lost !

> easier yet, abandon your NIH-syndrome doubly linked list class and use
> java.util.ArrayList, which already implements Serializable.

Cant, because i need some customized methods that can only be
implemented with a DLL.

P.S : Google Groups is "Oops" on me and this is the only way i can post
atm.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.