Serializable interface and Double-Linked List

Discussion in 'Java' started by Bulkan@gmail.com, Jan 9, 2006.

  1. Guest

    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
    {
    }
     
    , Jan 9, 2006
    #1
    1. Advertising

  2. Chris Smith Guest

    <> 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
     
    Chris Smith, Jan 9, 2006
    #2
    1. Advertising

  3. placid Guest

    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.
     
    placid, Jan 9, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sydex
    Replies:
    12
    Views:
    6,510
    Victor Bazarov
    Feb 17, 2005
  2. fool
    Replies:
    14
    Views:
    515
    Barry Schwarz
    Jul 3, 2006
  3. joshd
    Replies:
    12
    Views:
    675
    John Carson
    Oct 2, 2006
  4. Jimmy
    Replies:
    4
    Views:
    646
    Thomas Hawtin
    Aug 8, 2007
  5. Replies:
    8
    Views:
    3,027
Loading...

Share This Page