Interface ResourceLoader
-
public interface ResourceLoaderA loader for resources.The Java module system does not allow access to non-exported packages. That also includes access to resources in folders that don't match exported packages. The
TestResourceannotation will fail to load such resources. This interface makes it possible to define a custom resource loader that does have access to non-exported resources. In most cases, an implementation will simply delegate toClass.getResourceAsStream(String)to access resources from its own module.- Author:
- Rob Spoor
- Since:
- 3.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description InputStreamloadResource(Class<?> c, String path)Opens a resource if possible.
-
-
-
Method Detail
-
loadResource
InputStream loadResource(Class<?> c, String path)
Opens a resource if possible. The resource will be loaded relative to the class where the field, constructor or method is defined.- Parameters:
c- The class that acts as base path for the resource to open.path- The path to the resource, relative to the given class.- Returns:
- An
InputStreamto the resource, ornullif the resource could not be found.
-
-