开发者

Equivalent of C# OnDeserialized/OnSerializaed in Java?

Is there an equivalent to the C# [OnSerialized] and [开发者_C百科OnDeserialized] attributes in Java?


If you're using default Java serialization, you can override the methods used to serialize and deserialize. These methods are:

private void writeObject(ObjectOutputStream out) throws IOException
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException

Just call the "default" method for each of these: out.defaultWriteObject(out) and in.defaultReadObject(in).

There's a very detailed article on Java serializtion at http://java.sun.com/developer/technicalArticles/Programming/serialization/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜