/** * Variables to be replaced in a resource file should be in the format: $variableName$ The * variable to replace in the file should also also match the parameter names of the method * calling getFileContent. * * @param filePath * @param params * @param classRelativeToResource * @return */ public static String getFileContent( String filePath, ImmutableMap<String, String> params, Class classRelativeToResource) { StrSubstitutor strSubstitutor = new StrSubstitutor(params); strSubstitutor.setVariablePrefix(RESOURCE_VARIABLE_DELIMETER); strSubstitutor.setVariableSuffix(RESOURCE_VARIABLE_DELIMETER); String fileContent; try { fileContent = IOUtils.toString( classRelativeToResource.getClassLoader().getResourceAsStream(filePath), "UTF-8"); } catch (IOException e) { throw new RuntimeException("Failed to read filepath: " + filePath); } return strSubstitutor.replace(fileContent); }