Interface Template.ResourceOpener
- Enclosing class:
Template
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Used to resolve references to resources in the template, through
#parse
directives.
Here is an example that opens nested templates as resources relative to the calling class:
ResourceOpener resourceOpener = resourceName -> { InputStream inputStream = getClass().getResource(resourceName); if (inputStream == null) { throw new IOException("Unknown resource: " + resourceName); } return new BufferedReader(InputStreamReader(inputStream, StandardCharsets.UTF_8)); };
-
Method Summary
Modifier and TypeMethodDescriptionopenResource
(String resourceName) Returns a Reader that will be used to read the given resource, then closed.
-
Method Details
-
openResource
Returns a Reader that will be used to read the given resource, then closed.- Parameters:
resourceName
- the name of the resource to be read. This will never be null.- Throws:
IOException
-