二进制流实现深复制

	public static Object depthClone(Object srcObj) throws IOException, ClassNotFoundException{
		Object cloneObj = null;
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		ObjectOutputStream oo = new ObjectOutputStream(out);
		oo.writeObject(srcObj);
		ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
		ObjectInputStream oi = new ObjectInputStream(in);
		cloneObj = oi.readObject();
		return cloneObj;
	}

你可能感兴趣的:(clone,深拷贝)