欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

java的,

来源: javaer 分享于  点击 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();
    }




相关文章

    暂无相关文章
相关栏目:

用户点评