Java examples for java.lang:Object
deep Copy List
//package com.java2s; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.List; public class Main { public static <T> List<T> deepCopyList(List<T> src) throws IOException, ClassNotFoundException { ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(byteOut); out.writeObject(src);// ww w .j a va2 s . c om ByteArrayInputStream byteIn = new ByteArrayInputStream( byteOut.toByteArray()); ObjectInputStream in = new ObjectInputStream(byteIn); List<T> dest = (List<T>) in.readObject(); return dest; } }