Skip to content

Commit 3b7b811

Browse files
committed
fix: resources stream close error
1 parent 396c060 commit 3b7b811

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

vrml-resource/src/main/java/group/rxcloud/vrml/resource/JavaFileLoader.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@ final class JavaFileLoader {
2222
*/
2323
static InputStreamReader loadJavaResources(String fileName) throws NullPointerException, IllegalArgumentException {
2424
Objects.requireNonNull(fileName, "fileName not found.");
25-
try (InputStream in = JavaFileLoader.class.getResourceAsStream(fileName)) {
26-
return new InputStreamReader(in, StandardCharsets.UTF_8);
27-
} catch (Exception e) {
28-
throw new IllegalArgumentException(fileName + " file not found.", e);
29-
}
25+
InputStream in = JavaFileLoader.class.getResourceAsStream(fileName);
26+
return new InputStreamReader(in, StandardCharsets.UTF_8);
3027
}
3128

3229
/**
@@ -42,9 +39,8 @@ static InputStreamReader loadSystemFile(String fileName) throws NullPointerExcep
4239
try {
4340
File file = new File(fileName);
4441
if (file.exists() && file.canRead()) {
45-
try (FileInputStream fis = new FileInputStream(file)) {
46-
return new InputStreamReader(fis, StandardCharsets.UTF_8);
47-
}
42+
FileInputStream fis = new FileInputStream(file);
43+
return new InputStreamReader(fis, StandardCharsets.UTF_8);
4844
}
4945
} catch (Exception e) {
5046
throw new IllegalArgumentException(fileName + " file not found.", e);

0 commit comments

Comments
 (0)