diff options
author | NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> | 2024-04-27 04:56:48 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-26 20:56:48 +0200 |
commit | d3106bf41e099d329d9db330ab09e167519fce25 (patch) | |
tree | ff2a0d1a2c426dd43ee66568ee798aeb188cada6 | |
parent | 3231e1c6da4a81b8c574ffd786d867d207912e54 (diff) | |
download | NotEnoughUpdates-d3106bf41e099d329d9db330ab09e167519fce25.tar.gz NotEnoughUpdates-d3106bf41e099d329d9db330ab09e167519fce25.tar.bz2 NotEnoughUpdates-d3106bf41e099d329d9db330ab09e167519fce25.zip |
Fix fairy soul json being locked by the first instance of the game (#1114)
-rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java index 52ce46a1..e447e4a9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FairySouls.java @@ -46,9 +46,11 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -317,11 +319,9 @@ public class FairySouls { public void loadFoundSoulsForAllProfiles(File file, Gson gson) { allProfilesFoundSouls = new HashMap<>(); String fileContent; - try { - fileContent = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)) - .lines() - .collect(Collectors.joining(System.lineSeparator())); - } catch (FileNotFoundException e) { + try (BufferedReader br = Files.newBufferedReader(file.toPath())) { + fileContent = br.lines().collect(Collectors.joining(System.lineSeparator())); + } catch (IOException e) { // it is possible that the collected_fairy_souls.json won't exist return; } |