- 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());
- }