Here you can find the source of serializedCopy(Object obj)
public static Object serializedCopy(Object obj)
//package com.java2s; //License from project: Apache 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 serializedCopy(Object obj) { try {/*from www . j a v a2 s . co m*/ return deserialize(serialize(obj)); } catch (ClassNotFoundException e) { throw new RuntimeException("this shouldn't happen"); } } public static Object deserialize(byte[] bytes) throws ClassNotFoundException { try { ByteArrayInputStream input = new ByteArrayInputStream(bytes); ObjectInputStream ois = new ObjectInputStream(input); return ois.readObject(); } catch (IOException e) { throw new RuntimeException("error reading from byte-array!", e); } } public static byte[] serialize(Object obj) { try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(buffer); oos.writeObject(obj); oos.close(); return buffer.toByteArray(); } catch (IOException e) { throw new RuntimeException("error writing to byte-array!", e); } } }