Resources { @Pure public static InputStream getResourceAsStream(String path) { try { final Class<?> type = Caller.getCallerClass(1); if (type != null) { return getResourceAsStream(type, path); } } catch (Throwable exception) { } return getResourceAsStream((ClassLoader) null, path); } private  Resources(); @Pure static URL getResource(String path); @Pure @Deprecated(since = "17.0") static URL getResource(ClassLoader classLoader, Package packagename, String path); @Pure static URL getResource(Class<?> classname, String path); @Pure @Deprecated(since = "17.0") static URL getResource(ClassLoader classLoader, String path); @Pure static InputStream getResourceAsStream(String path); @Pure @Deprecated(since = "17.0") static InputStream getResourceAsStream(ClassLoader classLoader, Package packagename, String path); @Pure static InputStream getResourceAsStream(Class<?> classname, String path); @Pure @Deprecated(since = "17.0") static InputStream getResourceAsStream(ClassLoader classLoader, String path); @Pure static URL getPropertyFile(Class<?> classname, Locale locale); @Pure @Deprecated(since = "17.0") static URL getPropertyFile(ClassLoader classLoader, Class<?> classname, Locale locale); @Pure static String translateResourceName(String resourceName); static final String NAME_SEPARATOR; }
@Test public void getResourceAsStreamString() throws IOException { assertNull(Resources.getResourceAsStream(null)); try (InputStream is = Resources.getResourceAsStream(TEST_NAME_1)) { assertNotNull(is); } try (InputStream is = Resources.getResourceAsStream(TEST_NAME_2)) { assertNotNull(is); } }
@Test public void getResourceAsStreamClassString() throws IOException { assertNull(Resources.getResourceAsStream(ResourcesTest.class, null)); try (InputStream is = Resources.getResourceAsStream(ResourcesTest.class, TEST_NAME_1)) { assertNotNull(is); } try (InputStream is = Resources.getResourceAsStream(ResourcesTest.class, TEST_NAME_2)) { assertNotNull(is); } try (InputStream is = Resources.getResourceAsStream(ResourcesTest.class, TEST_NAME_3)) { assertNotNull(is); } try (InputStream is = Resources.getResourceAsStream(ResourcesTest.class, TEST_NAME_4)) { assertNotNull(is); } assertNull(Resources.getResourceAsStream((Class<?>)null, null)); try (InputStream is = Resources.getResourceAsStream((Class<?>)null, TEST_NAME_1)) { assertNull(is); } try (InputStream is = Resources.getResourceAsStream((Class<?>)null, TEST_NAME_2)) { assertNull(is); } try (InputStream is = Resources.getResourceAsStream((Class<?>)null, TEST_NAME_3)) { assertNull(is); } }