Package io.micronaut.core.io.file
Class DefaultFileSystemResourceLoader
- java.lang.Object
-
- io.micronaut.core.io.file.DefaultFileSystemResourceLoader
-
- All Implemented Interfaces:
FileSystemResourceLoader
,ResourceLoader
public class DefaultFileSystemResourceLoader extends java.lang.Object implements FileSystemResourceLoader
Loads resources from the file system.- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description DefaultFileSystemResourceLoader()
Default constructor.DefaultFileSystemResourceLoader(java.io.File baseDirPath)
DefaultFileSystemResourceLoader(java.lang.String path)
DefaultFileSystemResourceLoader(java.nio.file.Path path)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourceLoader
forBase(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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.micronaut.core.io.file.FileSystemResourceLoader
supportsPrefix
-
-
-
-
Constructor Detail
-
DefaultFileSystemResourceLoader
public DefaultFileSystemResourceLoader()
Default constructor.
-
DefaultFileSystemResourceLoader
public DefaultFileSystemResourceLoader(java.io.File baseDirPath)
- Parameters:
baseDirPath
- The base directory
-
DefaultFileSystemResourceLoader
public DefaultFileSystemResourceLoader(java.lang.String path)
- Parameters:
path
- The path
-
DefaultFileSystemResourceLoader
public DefaultFileSystemResourceLoader(java.nio.file.Path path)
- Parameters:
path
- The path
-
-
Method Detail
-
getResourceAsStream
public java.util.Optional<java.io.InputStream> getResourceAsStream(java.lang.String path)
Description copied from interface:ResourceLoader
Obtains a resource as a stream.- Specified by:
getResourceAsStream
in interfaceResourceLoader
- Parameters:
path
- The path- Returns:
- An optional resource
-
getResource
public java.util.Optional<java.net.URL> getResource(java.lang.String path)
Description copied from interface:ResourceLoader
Obtains the URL to a given resource.- Specified by:
getResource
in interfaceResourceLoader
- Parameters:
path
- The path- Returns:
- An optional resource
-
getResources
public java.util.stream.Stream<java.net.URL> getResources(java.lang.String name)
Description copied from interface:ResourceLoader
Obtains all resources with the given name.- Specified by:
getResources
in interfaceResourceLoader
- Parameters:
name
- The name of the resource- Returns:
- A stream of URLs
-
forBase
public ResourceLoader forBase(java.lang.String basePath)
Description copied from interface:ResourceLoader
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.- Specified by:
forBase
in interfaceResourceLoader
- Parameters:
basePath
- The path to load resources- Returns:
- The resource loader
-
-