Here you can find the source of deepCopy(T src)
public static <T> T deepCopy(T src) throws IOException, CloneNotSupportedException, ClassNotFoundException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static <T> T deepCopy(T src) throws IOException, CloneNotSupportedException, ClassNotFoundException { if (!(src instanceof Serializable)) { throw new CloneNotSupportedException( "src is not Serializable class"); }/* w w w.ja v a 2 s . c o m*/ ByteArrayOutputStream bout = null; ObjectOutputStream oout = null; ByteArrayInputStream bin = null; ObjectInputStream oin = null; try { bout = new ByteArrayOutputStream(); oout = new ObjectOutputStream(bout); oout.writeObject(src); oout.flush(); byte[] serialized = bout.toByteArray(); bin = new ByteArrayInputStream(serialized); oin = new ObjectInputStream(bin); T copyedObject = (T) oin.readObject(); return copyedObject; } finally { bout.close(); oout.close(); bin.close(); oin.close(); } } }