Java对象反序列化流
作者:互联网
一、对象反序列化流: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();
}
}
标签:Java,ObjectInputStream,对象,Object,InputStream,序列化,ois 来源: https://blog.csdn.net/feizuiku0116/article/details/122350130