@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 (IOException e) { } catch (ClassNotFoundException e) { } return dest; }
文章出处:https://blog.csdn.net/azhegps/article/details/53189811