public class ListUtilsService {
/**
* 描述:list集合深拷贝
* 2018年7月22日下午2:35:23
*/
public List deepCopy(List src) {
try {
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 dest = (List) in.readObject();
return dest;
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}
list集合深拷贝
最新推荐文章于 2024-07-14 21:34:05 发布