`
a25765339
  • 浏览: 61077 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

java深克隆

 
阅读更多
public Object deepClone(Object obj) throws Exception{
		//将对象写入流
		ByteArrayOutputStream bo = new ByteArrayOutputStream();
		ObjectOutputStream oo = new ObjectOutputStream(bo);
		oo.writeObject(obj);
		//从流中读取对象
		ByteArrayInputStream bi = new ByteArrayInputStream(bo.toByteArray());
		ObjectInputStream bis = new ObjectInputStream(bi);
		return bis.readObject();
	}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics