Here you can find the source of deepClone(Serializable o)
public static Object deepClone(Serializable o)
//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 { public static Object deepClone(Serializable o) { return deserialize(serialize(o)); }//from w w w. j av a 2 s. c om /** @author Found this one on StackOverflow */ public static Object deserialize(byte[] bytes) { try { ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(bais); return ois.readObject(); } catch (Exception e) { throw new RuntimeException(e); } } /** @author Found this one on StackOverflow */ public static byte[] serialize(Serializable o) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(o); return baos.toByteArray(); } catch (Exception e) { throw new RuntimeException(e); } } }