序列化实现深克隆
public static Object deepClone(Object source) {
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
File file = null;
try {
FileOutputStream fos = new FileOutputStream(objFile)
oos = new ObjectOutputStream(fos)
ooswriteObject(source)
FileInputStream fis = new FileInputStream(objFile)
ois = new ObjectInputStream(fis)
return oisreadObject()
} catch (Exception e) {
Systemerrprintln(对象克隆失败)
eprintStackTrace()
return null;
} finally {
try {
if(null != oos) {
oosclose()
}
if(null != ois) {
oisclose()
}
file = new File(objFile)
if(null != file) {
filedelete()
}
} catch (IOException e) {
eprintStackTrace()
}
}
}