Here you can find the source of deepCopy(T t)
public static <T> T deepCopy(T t) throws IOException, ClassNotFoundException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static <T> T deepCopy(T t) throws IOException, ClassNotFoundException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(t);//from w w w . jav a 2 s . co m ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bis); return (T) ois.readObject(); } }