java 列表深拷贝
作者:
正在加载更多 | 来源:发表于
2018-10-22 10:31 被阅读0次private static <T> List<T> deepCopy(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);
List<T> dest = (List<T>) in.readObject();
return dest;
}
本文标题:java 列表深拷贝
本文链接:https://www.haomeiwen.com/subject/vtbwzftx.html
网友评论