- public Object deepClone()
- throws IOException, ClassNotFoundException {
- //将对象写入流
- 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());
- }
java深度clone
最新推荐文章于 2025-01-21 11:45:00 发布