Here you can find the source of serializedCopy(T object)
@SuppressWarnings("unchecked") static <T> T serializedCopy(T object)
//package com.java2s; //License from project: LGPL import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; public class Main { @SuppressWarnings("unchecked") static <T> T serializedCopy(T object) { try {// www . j a v a2 s .c o m ByteArrayOutputStream baout = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baout); out.writeObject(object); out.flush(); ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(baout.toByteArray())); return (T) in.readObject(); } catch (Exception e) { throw new AssertionError(e); } } }