public class SerialCloneable implements Cloneable,Serializable {
public Object clone()throws CloneNotSupportedException{
try{
ByteArrayOutputStream bout = new ByteArrayOutputStream();
try(ObjectOutputStream out = new ObjectOutputStream(bout)){
out.writeObject(this);
}
try(ObjectInputStream in = new ObjectInputStream(
new ByteArrayInputStream(bout.toByteArray()))){
return in.readObject();
}
}
catch (IOException | ClassNotFoundException e){
CloneNotSupportedException e2 = new CloneNotSupportedException();
e2.initCause(e);
throw e2;
}
}
}