public static Object serializeClone(final Object obj) throws IOException, ClassNotFoundException {
  ByteArrayOutputStream memOut=new ByteArrayOutputStream();
  ObjectOutputStream objOut=new ObjectOutputStream(memOut);
  objOut.writeObject(obj);
  objOut.close();
  ByteArrayInputStream src=new ByteArrayInputStream(memOut.toByteArray());
  ObjectInputStream objIs=new ObjectInputStream(src);
  return objIs.readObject();
}

public static Object serializeClone ( final Object obj ) throws IOException , ClassNotFoundException { ByteArrayOutputStream memOut = new ByteArrayOutputStream ( ) ; ObjectOutputStream objOut = new ObjectOutputStream ( memOut ) ; objOut . writeObject ( obj ) ; objOut . close ( ) ; ByteArrayInputStream src = new ByteArrayInputStream ( memOut . toByteArray ( ) ) ; ObjectInputStream objIs = new ObjectInputStream ( src ) ; return objIs . readObject ( ) ; }
creates a clone by serializing object and deserializing byte stream .
