深度clone

其中的this为要clone对象

    public Object deepClone() 
        throws IOException, ClassNotFoundException {
        //将对象写入流
        ByteArrayOutputStream bo =
            new ByteArrayOutputStream();
        ObjectOutputStream oo =
            new ObjectOutputStream(bo);
        oo.writeObject(this);
        
        //从流里读回来
        ByteArrayInputStream bi =
            new ByteArrayInputStream(bo.toByteArray());
        ObjectInputStream oi =
            new ObjectInputStream(bi);
        
        return (oi.readObject());
    }


等偶有钱了,IBM,一下买3个:1个放家里-看黄片;1个随身带-聊天泡妞;1个放阳台-看着它生锈!

你可能感兴趣的:(IBM,OO,idea)