1、对象的深度clone方法
public static Object Clone(Object obj) throws Exception{
Object nObj = null;
try {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bout);
out.writeObject(obj);
out.close();
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
ObjectInputStream in = new ObjectInputStream(bin);
nObj = in.readObject();
in.close();
} catch (Exception e) {
throw new Exception("Object inputed can't be cloned.");
}
return nObj;
}