首页 > 其他 > 详细

list的深度复制

时间:2020-02-04 16:18:30      阅读:77      评论:0      收藏:0      [点我收藏+]
public class DeepCopyUtils {

public static <T> List<T> deepCopyList(List<T> src) throws IOException, ClassNotFoundException {

ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteOut);
out.writeObject(src);
ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
ObjectInputStream in = new ObjectInputStream(byteIn);
@SuppressWarnings("unchecked")
List<T> dest = (List<T>) in.readObject();
return dest;
}

}

list的深度复制

原文:https://www.cnblogs.com/Husir-boky/p/12259736.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!