Here you can find the source of deepClone(Object objToClone)
public static Object deepClone(Object objToClone)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static Object deepClone(Object objToClone) { try {//from w ww. ja v a2s. com ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(objToClone); ByteArrayInputStream bais = new ByteArrayInputStream( baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); Object deepCopy = ois.readObject(); return deepCopy; } catch (Exception e) { System.out.println("deep clone failed"); e.printStackTrace(); return null; } } }