@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 |
|---|---|
java.io.Reader |
openResource(java.lang.String resourceName)
Returns a Reader that will be used to read the given resource, then closed.
|
java.io.Reader openResource(java.lang.String resourceName)
throws java.io.IOException
resourceName - the name of the resource to be read. This will never be null.java.io.IOExceptionCopyright © 2018 Google, Inc.. All Rights Reserved.