From 61d4c220841ad3d469c89a586c1f593fe02473b3 Mon Sep 17 00:00:00 2001 From: David Gerber Date: Sat, 24 Aug 2024 08:44:36 +0200 Subject: [PATCH] Use try-with-resource --- common/src/main/java/io/xeres/common/util/OsUtils.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/common/src/main/java/io/xeres/common/util/OsUtils.java b/common/src/main/java/io/xeres/common/util/OsUtils.java index c2b37529..680e821a 100644 --- a/common/src/main/java/io/xeres/common/util/OsUtils.java +++ b/common/src/main/java/io/xeres/common/util/OsUtils.java @@ -322,12 +322,10 @@ public static void setFileSecurity(Path path, boolean trusted) Objects.requireNonNull(path); if (SystemUtils.IS_OS_WINDOWS) { - try + try (var ads = new RandomAccessFile(path + ":Zone.Identifier", "rw")) // We can't use Path.of() here as it won't accept the ':' { - var ads = new RandomAccessFile(path + ":Zone.Identifier", "rw"); // We can't use Path.of() here as it won't accept the ':' byte[] data = ("[ZoneTransfer]\r\nZoneId=" + (trusted ? "2" : "3") + "\r\nHostUrl=about:internet\r\n").getBytes(); ads.write(data); - ads.close(); } catch (IOException e) {