How to read from file to Set with objectInputStream

我与影子孤独终老i 提交于 2020-06-22 04:31:41

问题


I'm trying to read some information from a file with ObjectInputStream method. For some reason, the file does not contain the information after the command executed.

No error appears.

This is my code :

public boolean findUser(String user_id) throws Exception {          

    try (ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(fILENAME))){
        //System.out.println("Adsfasdf");
        System.out.println(objectInputStream);
        Set<MarkoliaUser> users = (Set<MarkoliaUser>) objectInputStream.readObject();
        for(MarkoliaUser user : users)
            System.out.println(user.toString());
    }

    return true;
}

Please advise,

来源:https://stackoverflow.com/questions/62333962/how-to-read-from-file-to-set-with-objectinputstream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!