Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/main/java/com/resend/util/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}