readSerializableObj
package JBJADV003;
import java.io.*;
public class readSerializableObj {
public static void main(String[] args) throws IOException, ClassNotFoundException {
ObjectInputStream ois=null;
try{
//創建ObjectOutputStream輸出流
ois=new ObjectInputStream(new FileInputStream("c:\\myDoc\\stu.txt"));
//反序列化,強轉類型
Student stu=(Student)ois.readObject();
//輸出生成后對象信息
System.out.println("姓名為:"+stu.getName());
System.out.println("年齡為:"+stu.getAge());
System.out.println("性別為:"+stu.getGender());
System.out.println("密碼為:"+stu.getpassword());
}catch(IOException ex){
ex.printStackTrace();
}finally{
if(ois!=null){
ois.close();
}
}
}
}
轉載于:https://www.cnblogs.com/JesseCary/p/4504394.html
總結
以上是生活随笔為你收集整理的readSerializableObj的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux系统判断是否重启、关机、查询登
- 下一篇: Extjs4:改变Grid单元格背景色(