private static Template fromStream(InputStream templateStream) {
        if(templateStream == null) {
            throw new IllegalArgumentException("Null template stream");
        }
        BufferedReader reader = new BufferedReader(new InputStreamReader(templateStream));
        try {
            try {
                StringBuilder buffer = new StringBuilder();
                String line;
                while ((line = reader.readLine()) != null) {
                    buffer.append(line);
                    buffer.append('\n');
                }
                return new Template(buffer.toString());
            } finally {
                reader.close();
            }
        } catch (IOException e) {
            throw new IllegalArgumentException(e);
        }
    }
A single class templating library for doing runtime code-gen.

Not Threadsafe.
jctools-channels/src/main/java/org/jctools/util/Template.java