We know during serialization if superclass is serialize then subclass will automatically will become serialize so to prevent subclass to serialize we can do by overriding following below code in subclass
you can use the private methods to just throw
the NotSerializableException. below code you can add
private void writeObject(ObjectOutputStream out) throws IOException
{
throw new NotSerializableException("Not today!");
}
private void readObject(ObjectInputStream in) throws IOException
{
throw new NotSerializableException("Not today!");
}
you can use the private methods to just throw
the NotSerializableException. below code you can add
private void writeObject(ObjectOutputStream out) throws IOException
{
throw new NotSerializableException("Not today!");
}
private void readObject(ObjectInputStream in) throws IOException
{
throw new NotSerializableException("Not today!");
}
No comments:
Post a Comment