package com.imooc.learn1;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class ObjectSeialDemo {
public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
String file="e:\\HTML\\obj.bat";
// //对象的序列化
// ObjectOutputStream out=new ObjectOutputStream(new FileOutputStream(file));
// Student st=new Student("001", "ZhangSan", 22);
// out.writeObject(st);
// out.flush();
// out.close();
ObjectInputStream in=new ObjectInputStream(new FileInputStream(file));
Student stu=(Student) in.readObject();
System.out.println(stu.getName());
in.close();
}
}
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class ObjectSeialDemo {
public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
String file="e:\\HTML\\obj.bat";
// //对象的序列化
// ObjectOutputStream out=new ObjectOutputStream(new FileOutputStream(file));
// Student st=new Student("001", "ZhangSan", 22);
// out.writeObject(st);
// out.flush();
// out.close();
ObjectInputStream in=new ObjectInputStream(new FileInputStream(file));
Student stu=(Student) in.readObject();
System.out.println(stu.getName());
in.close();
}
}