Here you can find the source of deepCopy(List
public static <T> List<T> deepCopy(List<T> src)
//package com.java2s; //License from project: Apache License 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> deepCopy(List<T> src) { ByteArrayOutputStream byteOut = null; ObjectOutputStream out = null; try {// w w w. jav a 2 s.co m byteOut = new ByteArrayOutputStream(); out = new ObjectOutputStream(byteOut); out.writeObject(src); ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray()); ObjectInputStream in = new ObjectInputStream(byteIn); @SuppressWarnings("unchecked") List<T> dest = (List<T>) in.readObject(); return dest; } catch (Exception e) { e.printStackTrace(); return null; } finally { if (byteOut != null) { try { byteOut.close(); } catch (IOException e) { e.printStackTrace(); } } if (out != null) { try { out.close(); } catch (IOException e) { e.printStackTrace(); } } } } }