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();
}
}
}
}