/**
* Clone Object
* @param obj
* @return
* @throws Exception
*/
private static Object cloneObject(Object obj) throws Exception{
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteOut);
out.writeObject(obj);
ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
ObjectInputStream in =new ObjectInputStream(byteIn);
return in.readObject();
}
深度Clone以及序列化与反序列化的使用
最新推荐文章于 2024-06-21 08:04:53 发布