标题:关于对象串行化
取消只看楼主
sbihcmfkpgf
Rank: 2
等 级:论坛游民
帖 子:13
专家分:10
注 册:2007-5-19
 问题点数:0 回复次数:0 
关于对象串行化
当我保存了很多串行化对象时,比如说用户帐号和密码都在一个对象里面,当登录时,我得从保存文件里读与之相匹配的帐号和密码,但怎样判断文件到达末尾否?
假设如下代码:
       try{
           FileInputStream fi=new FileInputStream("xx.txt");
           ObjectInputStream is=new ObjectInputStream(fi);
           String theId="sbihc";
           String thePsw="132610";
           UserInfo ui=null;    //UserInfo为串行化类
           ui=(UserInfo)is.readObject();
           while(ui!=null){   //好象不能用此方法判断文件尾????
               if(theId.equals(ui.getId()) && thdPsw.equals(ui.getPsw()){
    }
            ui=(UserInfo)is.readObject();
           }
           is.close();
        }catch(Exception e){}
搜索更多相关主题的帖子: 串行 对象 UserInfo 帐号 
2008-06-02 08:04



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-217102-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.627472 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved