Similar to your solution you can compose all of your replace applications together into a single Function<String, String>
privatestaticvoidpopulateTemplateFile(Map<String,String>replacementMap){Filefile=newFile(TEMPLATE_FILE);/* Combine all of the replacements into a single function */Function<String,String>replacementFunction=replacementMap.entrySet().stream().map(kv->(Function<String,String>)s->s.replace(kv.getKey(),kv.getValue())).reduce(Function.identity(),Function::andThen);try(Stream<String>lines=Files.lines(Paths.get(file.toURI()));PrintWriteroutput=newPrintWriter(TARGET_FILE,"UTF-8")){lines.map(replacementFunction).forEachOrdered(output::println);}catch(IOExceptione){log.error("Exception while trying to create "+TARGET_FILE,e);}}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Similar to your solution you can compose all of your
replace
applications together into a singleFunction<String, String>