Java Object Deep Copy deepCopy(T t)

Here you can find the source of deepCopy(T t)

Description

deep Copy

License

Open Source License

Declaration

public static <T> T deepCopy(T t) throws IOException, ClassNotFoundException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    public static <T> T deepCopy(T t) throws IOException, ClassNotFoundException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(t);//from w  w  w  .  jav a 2 s . co  m
        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
        ObjectInputStream ois = new ObjectInputStream(bis);
        return (T) ois.readObject();

    }
}

Related

  1. deepCopy(Object toCopy)
  2. deepCopy(Serializable source)
  3. deepCopy(T item)
  4. deepCopy(T originalObject)
  5. deepCopy(T src)
  6. deeplyCopy(Serializable serializable)