Article View: borland.public.jbuilder.java.language
Article #18867Re: MVC & Serialization
From: Dave Whipple
Date: Thu, 09 Apr 1998 00:00
Date: Thu, 09 Apr 1998 00:00
29 lines
1620 bytes
1620 bytes
I could not get something like this to work, but what I did get to work was to make an object serialize its contents to a file and read them back in. I didn't serialize "this", but rather everything that was in 'this' and then when I read it back in, I set the values in the current object to what was read in. Satwant Bhumber wrote: > I'm trying to write a program that will serialize the model to a file. The > code to load and save is located > within functions within the model. > > Save seems to work fine > > the following code: > FileOutputStream fout = new FileOutputStream(filename); > ObjectOutputStream out = new ObjectOutputStream(fout); > out.writeObject(this); > > But load doesn't like "this". > FileInputStream fin = new FileInputStream(filename); > ObjectInputStream in = new ObjectInputStream(fin); > this = (LeagueSubject)in.readObject(); > in.close(); > > Does anyone know how to replace an object within it's own class? (if that > makes any sence!)
Technical Details
Message-ID:
<352CD17C.3420D4A1@softworkscc.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<6ggrpu$r2m2@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,8e08f0b8337bbed4 X-Google-Attributes: gidf74b3,public From: Dave Whipple <dwhipple@softworkscc.com> Subject: Re: MVC & Serialization Date: 1998/04/09 Message-ID: <352CD17C.3420D4A1@softworkscc.com> X-Deja-AN: 342411095 Content-Transfer-Encoding: 7bit References: <6ggrpu$r2m2@forums.borland.com> Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Reply-To: dwhipple@softworkscc.com Newsgroups: borland.public.jbuilder.java.language