🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #15030

Re: PrintWriter.println(Object) - any equivalent read(Object)?

#15030
From: Tor Iver Wilhelmsen
Date: Tue, 13 Jul 1999 00:00
19 lines
1179 bytes
"Lois Neo" <slneo@cybergal.com> writes:

> I have a problem with reading an object from a text file, previously written
> using the PrintWriter.println(MyObject) method.

This calls the object's toString() method and prints that. Not very
useful.

> I'm not sure how I can read
> it back from the file.

The string produced? Use bufferedReader.readLine().

> ObjectInputStream seems to work only for ObjectOutputStream written
> objects. I tried reading the object as String, but then dunno if
> there's any way I can convert it back to MyObject?

No, there isn't, unless you override toString() to produce a
representation you can use for constructing the object.
Technical Details
Message-ID: <ug12sapdy.fsf@sds.no>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7meq5t$sqd10@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,1470b9b9a4394f04
X-Google-Attributes: gidf74b3,public
From: Tor Iver Wilhelmsen <tor.wilhelmsen@sds.no>
Subject: Re: PrintWriter.println(Object) - any equivalent read(Object)?
Date: 1999/07/13
Message-ID: <ug12sapdy.fsf@sds.no>
X-Deja-AN: 500445838
Sender: towi@SDSA1761
References: <7meq5t$sqd10@forums.borland.com>
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.language