public static <E> E deepClone(E object) throws IOException, ClassNotFoundException {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
ObjectOutputStream oo = new ObjectOutputStream(bo);
oo.writeObject(object);
ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray());
ObjectInputStream oi = new ObjectInputStream(bi);
return (E)oi.readObject();
}
转载于:https://www.cnblogs.com/frankliiu-java/archive/2009/12/15/1624601.html