Java学习-反对象序列化流

package com.d04_file.itheima12;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
//反对象序列化流,从文件中读取对象信息
public class ObjectInputStreeamDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("src\\com\\d04_file\\itheima12\\oos.txt"));
        Object obj = ois.readObject();
        Student s = (Student) obj;
        System.out.println(s.getName()+","+s.getAge());
    }
}

 

上一篇:【02】MySQL:SQL 基础


下一篇:Java对象为啥要实现Serializable接口?