为什么在保存/加载到dat文件时会获得IOExeption?

时间:2016-04-20 14:08:48

标签: java javafx ioexception fileinputstream

我正在创建一个程序,用户输入姓名,身份证号码,日期,电子邮件和课程选择,然后将其保存到文件中。这是我的代码:

private class LoadMenuHandler implements EventHandler<ActionEvent> {
    public void handle(ActionEvent event) {
        try (ObjectInputStream loadData = new ObjectInputStream(new FileInputStream("ModuleChoices.dat"));) {
            profile = (StudentProfile) loadData.readObject();
            System.out.println("loaded");
        } catch (FileNotFoundException fnfExcept) {
            System.out.println("not found");
        } catch (IOException ioExcept) {
            System.out.println("Error loading");
        } catch (ClassNotFoundException e) {
            System.out.println("Class not found");
        }
        createProfile.setLoadProfile(profile);
    }
}

0 个答案:

没有答案