@@ -281,17 +281,43 @@ public static byte[] fileLoadToProgress(File file, Consumer<ProgressWriter.Write
281281
282282 /**
283283 * リソースフォルダからデータを抽出
284+ * {@link #resourceExtracted}を利用してください
284285 *
285286 * @param clazz リソースフォルダのクラス
286287 * @param path リソースパス
287288 * @return InputStream
288289 */
289290 @ Nullable
291+ @ Deprecated
290292 public static InputStream resourceExtractor (@ NotNull Class <?> clazz , @ NotNull String path ) {
293+ try {
294+ return resourceBufferedExtracted (clazz , path );
295+ } catch (IOException e ) {
296+ throw new RuntimeException (e );
297+ }
298+ }
299+
300+ /**
301+ * リソースフォルダからデータを抽出
302+ *
303+ * @param clazz リソースフォルダのクラス
304+ * @param path リソースパス
305+ * @return InputStream
306+ */
307+ public static InputStream resourceExtracted (@ NotNull Class <?> clazz , @ NotNull String path ) throws IOException {
291308 if (path .startsWith ("/" )) path = path .substring (1 );
292- InputStream stream = clazz .getResourceAsStream ("/" + path );
293- if (stream == null ) stream = ClassLoader .getSystemResourceAsStream (path );
294- return stream ;
309+
310+ try (InputStream stream = clazz .getResourceAsStream ("/" + path )) {
311+ if (stream != null )
312+ return stream ;
313+ }
314+
315+ try (InputStream stream = ClassLoader .getSystemResourceAsStream (path )) {
316+ if (stream != null )
317+ return stream ;
318+ }
319+
320+ return null ;
295321 }
296322
297323 /**
@@ -303,8 +329,8 @@ public static InputStream resourceExtractor(@NotNull Class<?> clazz, @NotNull St
303329 * @throws IOException 例外
304330 */
305331 @ Nullable
306- public static InputStream resourceBufferedExtractor (@ NotNull Class <?> clazz , @ NotNull String path ) throws IOException {
307- try (InputStream stream = resourceExtractor (clazz , path )) {
332+ public static InputStream resourceBufferedExtracted (@ NotNull Class <?> clazz , @ NotNull String path ) throws IOException {
333+ try (InputStream stream = resourceExtracted (clazz , path )) {
308334 if (stream != null ) {
309335 try (InputStream bufStream = new BufferedInputStream (stream )) {
310336 return bufStream ;
0 commit comments