📄 file26.java
字号:
import java.io.*;
///创建一个文件对象f
///创建一个输入流对象fis,并且以f作为参数
///创建一个对象序列化处理类的对象ois,并且以fis作为参数
///创建一个学生类st
///利用ois对象方法将st的属性值读出
public class file26
{
public static void main(String[] args)throws Exception
{
File f=new File("d://raf.txt");
FileInputStream fis=new FileInputStream(f);
ObjectInputStream ois=new ObjectInputStream(fis);
student st=new student();
st=(student)ois.readObject();
ois.close();
System.out.println(st.name);
System.out.println(st.age);
System.out.println(st.code);
System.out.println(st.school);
System.out.println(st.grade);
System.out.println(st.address);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -