diff --git a/app_pojavlauncher/src/main/assets/components/lwjgl3/version b/app_pojavlauncher/src/main/assets/components/lwjgl3/version index e9907d8f1..d210401e6 100644 --- a/app_pojavlauncher/src/main/assets/components/lwjgl3/version +++ b/app_pojavlauncher/src/main/assets/components/lwjgl3/version @@ -1 +1 @@ -1674881685730 \ No newline at end of file +1677612008557 \ No newline at end of file diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java index d12c12853..15973b608 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java @@ -523,7 +523,11 @@ public final class Tools { } File destinationFile = new File(output, outputName); if(!destinationFile.exists() || overwrite){ - IOUtils.copy(ctx.getAssets().open(fileName), new FileOutputStream(destinationFile)); + try(InputStream inputStream = ctx.getAssets().open(fileName)) { + try (OutputStream outputStream = new FileOutputStream(destinationFile)){ + IOUtils.copy(inputStream, outputStream); + } + } } } @@ -768,15 +772,19 @@ public final class Tools { } public static String read(InputStream is) throws IOException { - return IOUtils.toString(new InputStreamReader(is, StandardCharsets.UTF_8)); + String readResult = IOUtils.toString(is, StandardCharsets.UTF_8); + is.close(); + return readResult; } public static String read(String path) throws IOException { - return IOUtils.toString(new InputStreamReader(new FileInputStream(path), StandardCharsets.UTF_8)); + return read(new FileInputStream(path)); } public static void write(String path, String content) throws IOException { - IOUtils.write(content, new FileOutputStream(path)); + try(FileOutputStream outStream = new FileOutputStream(path)) { + IOUtils.write(content, outStream); + } } public static void downloadFile(String urlInput, String nameOutput) throws IOException { @@ -930,7 +938,9 @@ public final class Tools { final String name = getFileName(activity, uri); final File modInstallerFile = new File(activity.getCacheDir(), name); FileOutputStream fos = new FileOutputStream(modInstallerFile); - IOUtils.copy(activity.getContentResolver().openInputStream(uri), fos); + InputStream input = activity.getContentResolver().openInputStream(uri); + IOUtils.copy(input, fos); + input.close(); fos.close(); activity.runOnUiThread(() -> { alertDialog.dismiss(); diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/LayoutConverter.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/LayoutConverter.java index 209875648..7a842a39a 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/LayoutConverter.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/customcontrols/LayoutConverter.java @@ -21,7 +21,7 @@ public class LayoutConverter { public static boolean convertLookType = false; //false = flat; true = classic public static CustomControls loadAndConvertIfNecessary(String jsonPath) throws IOException, JsonSyntaxException { - String jsonLayoutData = IOUtils.toString(new InputStreamReader(new FileInputStream(jsonPath), StandardCharsets.UTF_8)); + String jsonLayoutData = Tools.read(jsonPath); try { JSONObject layoutJobj = new JSONObject(jsonLayoutData);