Java Utililty Methods Object Deep Clone

List of utility methods to do Object Deep Clone

Description

The list of methods to do Object Deep Clone are organized into topic(s).

Method

EdeepClone(final E object)
deep Clone
final E deepCopy = (E) doCopy(object);
return deepCopy;
TdeepClone(final T objectToBeClonned)
deep Clone
if (objectToBeClonned == null) {
    return null;
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
try {
    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    oos = new ObjectOutputStream(bos);
...
ObjectdeepClone(Object obj)
deep Clone
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
try {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    oos = new ObjectOutputStream(bos);
    oos.writeObject(obj);
    oos.flush();
    ByteArrayInputStream bin = new ByteArrayInputStream(bos.toByteArray());
...
ObjectdeepClone(Object objToClone)
deep Clone
try {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(objToClone);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bais);
    Object deepCopy = ois.readObject();
    return deepCopy;
...
ObjectdeepClone(Object src)
deep Clone
try {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(src);
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bais);
    return ois.readObject();
} catch (Exception e) {
...
ObjectdeepClone(Object src)
deep Clone
ByteArrayOutputStream betyArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(betyArrayOutputStream);
objectOutputStream.writeObject(src);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(betyArrayOutputStream.toByteArray());
ObjectInputStream objInputStream = new ObjectInputStream(byteArrayInputStream);
return objInputStream.readObject();
ObjectdeepClone(Serializable o)
deep Clone
return deserialize(serialize(o));
SerializabledeepClone(Serializable serializable)
deep Clone
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
new ObjectOutputStream(arrayOutputStream).writeObject(serializable);
ByteArrayInputStream bais = new ByteArrayInputStream(arrayOutputStream.toByteArray());
return (Serializable) new ObjectInputStream(bais).readObject();
TdeepClone(T toClone, final ClassLoader classLoader)
Creates a clone of any serializable object.
if (null == toClone)
    return null;
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
ObjectOutputStream oOut = new ObjectOutputStream(bOut);
oOut.writeObject(toClone);
oOut.close();
ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());
bOut.close();
...
ObjectdeepCloneObj(Object src)
deep Clone Obj
Object o = null;
try {
    if (src != null) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(src);
        oos.close();
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
...