复制对象
@param srcObj
@return
/
public static Object depthClone(Object srcObj) {
if (srcObj == null) {
return null;
}
Object cloneObj = null;
ByteArrayOutputStream out = null;
ObjectOutputStream oo = null;
ByteArrayInputStream in = null;
ObjectInputStream oi = null;
try {
out = new ByteArrayOutputStream();
oo = new ObjectOutputStream(out);
oowriteObject(srcObj);
in = new ByteArrayInputStream(outtoByteArray());
oi = new ObjectInputStream(in);
cloneObj = oireadObject();
} catch (IOException e) {
eprintStackTrace();
} catch (ClassNotFoundException e) {
eprintStackTrace();
} finally {
if (out != null) {
try {
outclose();
} catch (IOException ex) {
exprintStackTrace();
}
}
if (oo != null) {
try {
ooclose();
} catch (IOException ex) {
exprintStackTrace();
}
}
if (in != null) {
try {
inclose();
} catch (IOException ex) {
exprintStackTrace();
}
}
if (oi != null) {
try {
oiclose();
} catch (IOException ex) {
exprintStackTrace();
}
}
}
return cloneObj;
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)