diff --git a/src/main/java/com/resend/util/FileUtils.java b/src/main/java/com/resend/util/FileUtils.java index a4aa24b..25d54fd 100644 --- a/src/main/java/com/resend/util/FileUtils.java +++ b/src/main/java/com/resend/util/FileUtils.java @@ -12,10 +12,11 @@ public static String encodeFileToBase64(String filename) throws IOException { private static byte[] loadResourceFile(String filename) throws IOException { ClassLoader classLoader = FileUtils.class.getClassLoader(); - InputStream inputStream = classLoader.getResourceAsStream(filename); - if (inputStream == null) { - throw new IOException("Resource not found: " + filename); + try (InputStream inputStream = classLoader.getResourceAsStream(filename)) { + if (inputStream == null) { + throw new IOException("Resource not found: " + filename); + } + return inputStream.readAllBytes(); } - return inputStream.readAllBytes(); } -} \ No newline at end of file +}