clone复制对象

clone复制对象

public  Object cloneObject(Object obj) throws Exception{
  ByteArrayOutputStream  byteOut = new ByteArrayOutputStream();
  ObjectOutputStream out = new ObjectOutputStream(byteOut);
  out.writeObject(obj);
  ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());
  ObjectInputStream in =new ObjectInputStream(byteIn);
  return in.readObject();
  }
浅克隆:List billBoxListClone = (List)BeanUtils.cloneBean(billBoxList);

你可能感兴趣的:(clone复制对象)