Possible Duplicate:
Why is a serializable inner class not serializable?
I have a class that does not implement Serializable
. Inside of that class I have a data class which holds data for the whole program which implements Serializable
and has a version ID.
My problem is that when I try to serialze a data object with in my main class I get a object write error from the main class and not the data class. The main class does not implement Serializable
.
Can you serialize a class within a non-serializable class?
Example:
class main
{
class data implements Serializable
{ // data and functions }
public void main(args)
{ data d = new data();
// ofcourse I have the proper inits and checks for the output stream and such
writeObject(data); // Throws Class not Serializable error.}
}