public final class MyUtil {
private MyUtil(){
throw new AssertionError();
}
//复制文件
public static <T extends Serializable> T deepClone (T t){
ByteArrayOutputStream baos=new ByteArrayOutputStream();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
try(ObjectOutputStream oos=new ObjectOutputStream(baos);
ObjectInputStream ois=new ObjectInputStream(bais);){
oos.writeObject(t);
ois.readObject();
return t;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}