@FunctionalInterface public static interface Template.ResourceOpener
#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));
};
| Modifier and Type | Method and Description |
|---|---|
Reader |
openResource(String resourceName)
Returns a Reader that will be used to read the given resource, then closed.
|
Reader openResource(String resourceName) throws IOException
resourceName - the name of the resource to be read. This will never be null.IOExceptionCopyright © 2022. All rights reserved.