Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Serializable interface and Double-Linked List

Reply
Thread Tools

Serializable interface and Double-Linked List

 
 
Bulkan@gmail.com
Guest
Posts: n/a
 
      01-09-2006
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
{
}

 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      01-09-2006
<(E-Mail Removed)> wrote:
> 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.

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Reply With Quote
 
 
 
 
placid
Guest
Posts: n/a
 
      01-09-2006
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FindBugs complaining about non-serializable field although everythinglooks Serializable laredotornado@zipmail.com Java 8 01-15-2012 06:18 PM
Tips: What is the magic Serializable interface does in Java? Venkat Sadasivam Java 12 03-26-2008 12:38 PM
Object implements Serializable, but includes field(s) that do NOT implement Serializable Jimmy Java 4 08-08-2007 12:22 PM
Serializable interface on J2ME MIDP 1.0 device Thomas Hawtin Java 2 03-29-2006 07:50 PM
Sending object over network WITHOUT using serializable interface Steve Line Java 8 01-14-2004 12:08 AM



Advertisments