list<>集合通过io深度克隆
来源:互联网 发布:电子期刊在线阅读软件 编辑:程序博客网 时间:2024/05/21 14:48
/**
* 深度克隆
*
* @param src
* @return
*/
@SuppressWarnings("unchecked")
public static <T> List<T> deepCopyList(List<T> src) {
List<T> dest = null;
try {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteOut);
out.writeObject(src);
ByteArrayInputStream byteIn = new ByteArrayInputStream(
byteOut.toByteArray());
ObjectInputStream in = new ObjectInputStream(byteIn);
dest = (List<T>) in.readObject();
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
return dest;
}
* 深度克隆
*
* @param src
* @return
*/
@SuppressWarnings("unchecked")
public static <T> List<T> deepCopyList(List<T> src) {
List<T> dest = null;
try {
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteOut);
out.writeObject(src);
ByteArrayInputStream byteIn = new ByteArrayInputStream(
byteOut.toByteArray());
ObjectInputStream in = new ObjectInputStream(byteIn);
dest = (List<T>) in.readObject();
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
return dest;
}
阅读全文
0 0
- list<>集合通过io深度克隆
- List集合深度克隆
- java List深度克隆
- List的深度克隆
- 深度克隆
- 深度克隆
- 深度克隆
- 深度克隆
- 通过List集合进行分页
- java中list集合的深度拷贝
- 浅克隆和深度克隆
- 浅克隆与深度克隆
- 浅克隆与深度克隆
- 通过实现Cloneable接口和覆盖clone()方法实现深度克隆,以及如何通过ByteArrayIOStream实现克隆
- 通过List集合向前台显示文件类型
- 二维数组深度克隆
- java深度克隆
- c# 深度克隆
- zookeeper搭建
- c指针
- 服务器搭建solr
- 用python中的列表和字典实现名片管理系统
- Studio运行出现:This version of Android Studio is incompatible with the Gradle Plugin used. Try disablin
- list<>集合通过io深度克隆
- xpath定位
- 近期deep learning做图像质量评价(image quality assessment)的论文3
- 使用可变参数,实现函数,求函数参数的平均值和最大值
- super关键字的应用
- 修改Tomcat窗口名称
- html、css、js加载顺序
- [Oracle 11g r2 (11.2.0.4.0) ]设置共享服务连接方式
- 记一次ubuntu连上校园网但不能浏览网页