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.
@FunctionalInterface public static interface Template.ResourceOpener
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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.io.Reader
openResource(java.lang.String resourceName)
Returns a Reader that will be used to read the given resource, then closed.
-
-
-
Method Detail
-
openResource
java.io.Reader openResource(java.lang.String resourceName) throws java.io.IOException
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:
java.io.IOException
-
-