java的,
分享于 点击 17961 次 点评:5
java的,
<pre name="code" class="java">/**
申明:使用序列化进行深复制,凡是涉及到需要复制的类都必须实现Serializable接口。
*/
public Object deepCopy()
throws Exception
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(this);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bis);
return ois.readObject();
}
相关文章
- 暂无相关文章
用户点评