一、对象反序列化流:ObjectInputStream
ObjectInputStream反序列化先前使用ObjectOutputStream编写的原始数据和对象
二、构造方法
ObjectInputStream(InputStream in):创建从指定的InputStream读取的ObjectInputStream
三、反序列化对象的方法
Object readObject():从ObjectInputStream读取一个对象
四、实例
public class Test1 {
public static void main(String[] args) throws IOException, ClassNotFoundException {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("oos.txt"));
Object obj = ois.readObject();
Student s = (Student) obj;
System.out.println(s.getName()+","+s.getAge());
ois.close();
}
}