- /*
- * 复制对象obj,类似于值传递,非引用
- */
- public 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();
- }
java对象复制
最新推荐文章于 2024-07-12 14:26:09 发布