Java学习-反对象序列化流

2021/4/17 22:27:09

本文主要是介绍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学习-反对象序列化流的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程