diff --git a/src/main/java/es/kauron/jstudy/model/AppConfig.java b/src/main/java/es/kauron/jstudy/model/AppConfig.java index 89a6bd2..c086e48 100644 --- a/src/main/java/es/kauron/jstudy/model/AppConfig.java +++ b/src/main/java/es/kauron/jstudy/model/AppConfig.java @@ -22,19 +22,24 @@ public class AppConfig { } public static void load() { - try { - Scanner in = new Scanner(new File(FILE)); - while (in.hasNextLine()) { - String line = in.nextLine(); - String value = line.substring(line.indexOf('=') + 1); - if (line.matches("repeatWrong=.*")) - repeatWrong = Boolean.parseBoolean(value); - else if (line.matches("showFeedback=.*")) - showFeedback = Boolean.parseBoolean(value); + File file = new File(FILE); + if (!file.exists()) { + repeatWrong = true; + showFeedback = true; + } else + try { + Scanner in = new Scanner(new File(FILE)); + while (in.hasNextLine()) { + String line = in.nextLine(); + String value = line.substring(line.indexOf('=') + 1); + if (line.matches("repeatWrong=.*")) + repeatWrong = Boolean.parseBoolean(value); + else if (line.matches("showFeedback=.*")) + showFeedback = Boolean.parseBoolean(value); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); } - } catch (FileNotFoundException e) { - e.printStackTrace(); - } } public static String printValues() {