Here you can find the source of deepCopy(T item)
@SuppressWarnings("unchecked") public static <T extends Serializable> T deepCopy(T item)
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; public class Main { @SuppressWarnings("unchecked") public static <T extends Serializable> T deepCopy(T item) { if (item == null) return null; try {//from w ww .ja v a2 s .c o m ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(item); oos.flush(); byte[] rawData = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(rawData); ObjectInputStream ois = new ObjectInputStream(bais); return (T) ois.readObject(); } catch (Exception e) { } return null; } }