Package io.micronaut.core.io
Interface ResourceLoader
-
- All Known Subinterfaces:
ClassPathResourceLoader,FileSystemResourceLoader
- All Known Implementing Classes:
DefaultClassPathResourceLoader,DefaultFileSystemResourceLoader
@Indexed(ResourceLoader.class) public interface ResourceLoader
Basic abstraction over resource loading.- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ResourceLoaderforBase(java.lang.String basePath)Constructs a new resource loader designed to load resources from the given path.java.util.Optional<java.net.URL>getResource(java.lang.String path)Obtains the URL to a given resource.java.util.Optional<java.io.InputStream>getResourceAsStream(java.lang.String path)Obtains a resource as a stream.java.util.stream.Stream<java.net.URL>getResources(java.lang.String name)Obtains all resources with the given name.booleansupportsPrefix(java.lang.String path)
-
-
-
Method Detail
-
getResourceAsStream
java.util.Optional<java.io.InputStream> getResourceAsStream(java.lang.String path)
Obtains a resource as a stream.- Parameters:
path- The path- Returns:
- An optional resource
-
getResource
java.util.Optional<java.net.URL> getResource(java.lang.String path)
Obtains the URL to a given resource.- Parameters:
path- The path- Returns:
- An optional resource
-
getResources
java.util.stream.Stream<java.net.URL> getResources(java.lang.String name)
Obtains all resources with the given name.- Parameters:
name- The name of the resource- Returns:
- A stream of URLs
-
supportsPrefix
boolean supportsPrefix(java.lang.String path)
- Parameters:
path- The path to a resource including a prefix appended by a colon. Ex (classpath:, file:)- Returns:
- Whether the given resource loader supports the prefix
-
forBase
ResourceLoader forBase(java.lang.String basePath)
Constructs a new resource loader designed to load resources from the given path. Requested resources will be loaded within the context of the given path.- Parameters:
basePath- The path to load resources- Returns:
- The new
ResourceLoader
-
-