编程语言
首页 > 编程语言> > Java学习-反对象序列化流

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

 

标签:java,file,ObjectInputStream,学习,io,import,Java,序列化
来源: https://blog.csdn.net/qq_42776373/article/details/115802086