constructor loading it's object from a file
From: Murat Tasan (tasan_at_eecs.cwru.edu)
Date: 12/04/03
- Next message: Arvinder Channey: "non-rectangular GUI containers in java?????"
- Previous message: nos: "Re: Java expands wildcards in command line arguments in Windows: documentation"
- Next in thread: Raymond DeCampo: "Re: constructor loading it's object from a file"
- Reply: Raymond DeCampo: "Re: constructor loading it's object from a file"
- Reply: Amey Samant: "Re: constructor loading it's object from a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 3 Dec 2003 18:03:35 -0500
i'd like to have a constructor that loads an object from disk and returns
it... kinda like:
class MyClass
{
MyClass(File f)
{
ObjectInputStream s = new ObjectInputStream(new
FileInputStream(f));
this = (MyClass)s.readObject();
}
}
now i know you cannot do this because this in the constructor is a final
variable...
is there trick that i don't know of that can do this?
p.s., before i get the typical responses... i already am using a static
factory method to accomplish the same thing... i'm just looking to make it
even easier to use my classes.
thanks for any help,
murat
-- Murat Tasan mxt6@po.cwru.edu tasan@eecs.cwru.edu murat.tasan@cwru.edu http://genomics.cwru.edu
- Next message: Arvinder Channey: "non-rectangular GUI containers in java?????"
- Previous message: nos: "Re: Java expands wildcards in command line arguments in Windows: documentation"
- Next in thread: Raymond DeCampo: "Re: constructor loading it's object from a file"
- Reply: Raymond DeCampo: "Re: constructor loading it's object from a file"
- Reply: Amey Samant: "Re: constructor loading it's object from a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|