Here you can find the source of deepCopy(Object original)
public static Object deepCopy(Object original) throws IOException, ClassNotFoundException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; public class Main { public static Object deepCopy(Object original) throws IOException, ClassNotFoundException { ObjectInputStream ois;//w w w . j a v a 2 s .c om ObjectOutputStream oos; ByteArrayInputStream bais; ByteArrayOutputStream baos; byte[] data; Object copy; // write object to bytes baos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(baos); oos.writeObject(original); oos.close(); // get the bytes data = baos.toByteArray(); // construct an object from the bytes bais = new ByteArrayInputStream(data); ois = new ObjectInputStream(bais); copy = ois.readObject(); ois.close(); return copy; } }