diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/Main.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/Main.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/java/cuchaz/enigma/Main.java b/src/main/java/cuchaz/enigma/Main.java index b778946..dbbcee4 100644 --- a/src/main/java/cuchaz/enigma/Main.java +++ b/src/main/java/cuchaz/enigma/Main.java | |||
| @@ -18,6 +18,8 @@ import joptsimple.*; | |||
| 18 | 18 | ||
| 19 | import java.io.BufferedReader; | 19 | import java.io.BufferedReader; |
| 20 | import java.io.IOException; | 20 | import java.io.IOException; |
| 21 | import java.io.InputStreamReader; | ||
| 22 | import java.nio.charset.StandardCharsets; | ||
| 21 | import java.nio.file.Files; | 23 | import java.nio.file.Files; |
| 22 | import java.nio.file.Path; | 24 | import java.nio.file.Path; |
| 23 | import java.nio.file.Paths; | 25 | import java.nio.file.Paths; |
| @@ -49,12 +51,19 @@ public class Main { | |||
| 49 | return; | 51 | return; |
| 50 | } | 52 | } |
| 51 | 53 | ||
| 52 | EnigmaProfile parsedProfile = EnigmaProfile.EMPTY; | 54 | EnigmaProfile parsedProfile; |
| 53 | if (options.has(profile)) { | 55 | if (options.has(profile)) { |
| 54 | Path profilePath = options.valueOf(profile); | 56 | Path profilePath = options.valueOf(profile); |
| 55 | try (BufferedReader reader = Files.newBufferedReader(profilePath)) { | 57 | try (BufferedReader reader = Files.newBufferedReader(profilePath)) { |
| 56 | parsedProfile = EnigmaProfile.parse(reader); | 58 | parsedProfile = EnigmaProfile.parse(reader); |
| 57 | } | 59 | } |
| 60 | } else { | ||
| 61 | try (BufferedReader reader = new BufferedReader(new InputStreamReader(Main.class.getResourceAsStream("/profile.json"), StandardCharsets.UTF_8))){ | ||
| 62 | parsedProfile = EnigmaProfile.parse(reader); | ||
| 63 | } catch (IOException ex) { | ||
| 64 | System.out.println("Failed to load default profile, will use empty profile: " + ex.getMessage()); | ||
| 65 | parsedProfile = EnigmaProfile.EMPTY; | ||
| 66 | } | ||
| 58 | } | 67 | } |
| 59 | 68 | ||
| 60 | Gui gui = new Gui(parsedProfile); | 69 | Gui gui = new Gui(parsedProfile); |