readSerializableObj
package JBJADV003;
import java.io.*;
public class readSerializableObj {
public static void main(String[] args) throws IOException, ClassNotFoundException {
ObjectInputStream ois=null;
try{
//創(chuàng)建ObjectOutputStream輸出流
ois=new ObjectInputStream(new FileInputStream("c:\\myDoc\\stu.txt"));
//反序列化,強(qiáng)轉(zhuǎn)類型
Student stu=(Student)ois.readObject();
//輸出生成后對(duì)象信息
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();
}
}
}
}
轉(zhuǎn)載于:https://www.cnblogs.com/JesseCary/p/4504394.html
總結(jié)
以上是生活随笔為你收集整理的readSerializableObj的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: linux系统判断是否重启、关机、查询登
- 下一篇: Extjs4:改变Grid单元格背景色(