首页 > 其他 > 详细

WriteTeacherObj

时间:2015-05-15 01:02:06      阅读:288      评论:0      收藏:0      [点我收藏+]

package JBJADV003;
import java.io.*;
public class WriteTeacherObj {

/**
* @param args
*/
public static void main(String[] args)throws FileNotFoundException, IOException {
ObjectOutputStream oos=null;
try{
//创建ObjectOutputStream输出流
oos=new ObjectOutputStream(new FileOutputStream("c:\\myDoc\\tea.txt"));

Student stuZhang=new Student("韩冰",22,"女","123456");
Teacher teacherWang=new Teacher("王老师",stuZhang);
Teacher teacherLi=new Teacher("李老师",stuZhang);

//对象序列化,写入输出流
oos.writeObject(stuZhang);
oos.writeObject(teacherWang);
oos.writeObject(teacherLi);
}catch(IOException ex){
ex.printStackTrace();
}finally{
if(oos!=null){
oos.close();
}
}

}

}

WriteTeacherObj

原文:http://www.cnblogs.com/JesseCary/p/4504817.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!