[java]代码库
/**
* 深度复制
*/
public static Serializable deeplyCopy(Serializable src) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(src);
oos.close();
baos.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
Serializable copy = (Serializable) ois.readObject();
ois.close();
bais.close();
return copy;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}//源代码片段来自云代码http://yuncode.net