package cn.itcast_07;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class 序列化流和反序列化流的概述和使用 {
public static void main(String[] args) throws IOException, ClassNotFoundException {
writer();
reader();
}
private static void reader() throws IOException, IOException, ClassNotFoundException {
ObjectInputStream ois = new ObjectInputStream(
new FileInputStream("o.txt"));
Object obj = ois.readObject();
ois.close();
System.out.println(obj);
}
private static void writer() throws IOException, IOException {
ObjectOutputStream oss = new ObjectOutputStream(new FileOutputStream("o.txt"));
Student s1 = new Student("风从龙" , 123);
oss.writeObject(s1);
oss.close();
}
}