java List深度克隆

public static List deepCopy(List src) throws IOException, ClassNotFoundException{             
        ByteArrayOutputStream byteOut = new ByteArrayOutputStream();             
        ObjectOutputStream out = new ObjectOutputStream(byteOut);             
        out.writeObject(src);                    
        ByteArrayInputStream byteIn = new ByteArrayInputStream(byteOut.toByteArray());             
        ObjectInputStream in =new ObjectInputStream(byteIn);             
        List dest = (List)in.readObject();             
        return dest;         
    }   

猜你喜欢

转载自mysterious-9527.iteye.com/blog/2277122