IO流实现深克隆

@Test
	public void test2() throws Exception {
		Boy person = new Boy(18,"程柏薹");
		
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		
		ObjectOutputStream oos = new ObjectOutputStream(baos);
		oos.writeObject(person);
		
		ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
		ObjectInputStream ois = new ObjectInputStream(bais);
		Boy p2 = (Boy) ois.readObject();
		System.out.println(person+","+person.hashCode());
		System.out.println(p2+","+p2.hashCode());
		
	}

 

上一篇:CF1338B Edge Weight Assignment


下一篇:Opencv 图像处理-Contours函数提取轮廓及感兴趣区域ROI的必用且实用操作技巧-(涵盖Contours的一切使用基础,附代码段)