Array List 深拷贝

  1. public List deepCopy(List src) throws IOException, ClassNotFoundException{   
  2.         ByteArrayOutputStream byteOut = new ByteArrayOutputStream();   
  3.         ObjectOutputStream out = new ObjectOutputStream(byteOut);   
  4.         out.writeObject(src);   
  5.        
  6.         ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());   
  7.         ObjectInputStream in =new ObjectInputStream(byteIn);   
  8.         List dest = (List)in.readObject();   
  9.         return dest;   
  10.     }   

猜你喜欢

转载自patrick002.iteye.com/blog/2111709