序列化實現深克隆
public static Object deepClone(Object source) {
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
File file = null;
try {
FileOutputStream fos = new FileOutputStream(
oos = new ObjectOutputStream(fos)
oos
FileInputStream fis = new FileInputStream(
ois = new ObjectInputStream(fis)
return ois
} catch (Exception e) {
System
e
return null;
} finally {
try {
if(null != oos) {
oos
}
if(null != ois) {
ois
}
file = new File(
if(null != file) {
file
}
} catch (IOException e) {
e
}
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26113.html