出处:http://blog.csdn.net/dl88250/archive/2007/08/26/1759978.aspx
前拷贝需要实现Cloneable接口,深拷贝需要实现Serializable接口。
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());