"Firewalker" <> wrote in message
news:BRoJc.61$ rs.com...
> Hello guys,
> I am trying to create a linked list where its nodes are StringBuffer
> object. The thing that I wan to store this linked list somehow so that
when
> I reopen the java progra, it can loads the linked list again.
> I had a method in my mind which is to store an object in the file and read
> it back again.
> The thing that I dont know how to do it, Can anyone point me to the righ
> direction?
> Or if you have a different effective method, would you please give me
some
> help?
> Thanks alot for your help
If performance isn't critical, you could Serialize the object and write it
to a file using ObjectOutputStream. There are many serialization tutorials
out there, try here for starters (random Google result):
http://www.acm.org/crossroads/xrds4-2/serial.html
I mention performance because often serialization of objects isn't terribly
efficient compared to more specific saving strategies. There's overhead of
saving information about the class that is neede to regenerate the object.
There are also some gotchas, e.g. different versions of class files. But in
most cases performance isn't a problem and it's the easiest solution.