Re: constructor loading it's object from a file
From: Amey Samant (ameyas7_at_yahoo.com)
Date: 12/06/03
- Previous message: - Steve -: "Java StringTokenizer"
- In reply to: Murat Tasan: "constructor loading it's object from a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 5 Dec 2003 22:37:12 -0800
> class MyClass
> {
> MyClass(File f)
> {
> ObjectInputStream s = new ObjectInputStream(new
> FileInputStream(f));
> this = (MyClass)s.readObject();
> }
> }
>
how about instead of reading your object into this , read it in some
temporary local object variable & then perform member by member copy
into this
something of this sort
class MyClass
{
int x;
MyClass(File f)
{
MyClass temp;
ObjectInputStream s = new ObjectInputStream(new
FileInputStream(f));
temp= (MyClass)s.readObject();
this.x=temp.x; //member by member
copy for all members
}
}
hope this should help
regards
amey
- Previous message: - Steve -: "Java StringTokenizer"
- In reply to: Murat Tasan: "constructor loading it's object from a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|