SerializableObj

package JBJADV003;

import java.io.*;

public class SerializableObj {

/**
* @param args
* @throws IOException
* @throws FileNotFoundException
*/
public static void main(String[] args) throws FileNotFoundException, IOException {
ObjectOutputStream oos=null;
try{
//创建ObjectOutputStream输出流
oos=new ObjectOutputStream(new FileOutputStream("c:\\myDoc\\stu.txt"));
Student stu=new Student("安娜",30,"女","123456");
//对象序列化,写入输出流
oos.writeObject(stu);

}catch(IOException ex){
ex.printStackTrace();
}finally{
if(oos!=null){
oos.close();
}
}
}

}

posted on 2015-05-14 21:04  JesseCary  阅读(117)  评论(0)    收藏  举报

导航