Sherrod Faulks <bi****@verizon.net> wrote in news:2004082615122316807%
birded@verizonnet:
I have a class, Environment that implements java.io.Serializable and it
has a method public boolean store(java.io.File) that calls
java.io.ObjectOutputStream.defaultWriteObject() but when I do:
Environment e = new Environment();
e.store(...);
It raises java.io.NotActiveException. Can someone please explain this
and tell me how to get rid of it? Thanks!
The javadocs are your friend! They are available online, or can be
downloaded and installed on your computer.
From the javadoc for method defaultWriteObject of class ObjectOutputStream:
================================================== =========================
defaultWriteObject
public void defaultWriteObject()
throws IOExceptionWrite
the non-static and non-transient fields of the current class to this
stream. This may only be called from the writeObject method of the class
being serialized. It will throw the NotActiveException if it is called
otherwise.
Throws:
IOException - if I/O errors occur while writing to the underlying
OutputStream
================================================== =========================
Note the statement "This may only be called from the writeObject method of
the class being serialized. " Your call is violating this rule.
Why are you calling defaultWriteObject instead of calling writeObject ?
--
Ian Shef
These are my personal opinions and not those of my employer.