public static File replaceTokensInScript(
            final String script,
            final Map<String, Map<String, String>> dataContext,
            final Framework framework,
            final ScriptfileUtils.LineEndingStyle style,
            final File destination
    )
            throws IOException
    {
        if (null == script) {
            throw new NullPointerException("script cannot be null");
        }
        //use ReplaceTokens to replace tokens within the content
        final Reader read = new StringReader(script);
        final Map<String, String> toks = flattenDataContext(dataContext);
        final ReplaceTokenReader replaceTokens = new ReplaceTokenReader(read, toks::get, true, '@', '@');
        final File temp;
        if (null != destination) {
            ScriptfileUtils.writeScriptFile(null, null, replaceTokens, style, destination);
            temp = destination;
        } else {
            if (null == framework) {
                throw new NullPointerException("framework cannot be null");
            }
            temp = ScriptfileUtils.writeScriptTempfile(framework, replaceTokens, style);
        }
        ScriptfileUtils.setExecutePermissions(temp);
        return temp;
    }
public static File replaceTokensInScript ( final String script , final Map < String , Map < String , String > > dataContext , final Framework framework , final ScriptfileUtils . LineEndingStyle style , final File destination ) throws IOException { if ( null == script ) { throw new NullPointerException ( "script cannot be null" ) ; } final Reader read = new StringReader ( script ) ; final Map < String , String > toks = flattenDataContext ( dataContext ) ; final ReplaceTokenReader replaceTokens = new ReplaceTokenReader ( read , toks :: get , true , '@' , '@' ) ; final File temp ; if ( null != destination ) { ScriptfileUtils . writeScriptFile ( null , null , replaceTokens , style , destination ) ; temp = destination ; } else { if ( null == framework ) { throw new NullPointerException ( "framework cannot be null" ) ; } temp = ScriptfileUtils . writeScriptTempfile ( framework , replaceTokens , style ) ; } ScriptfileUtils . setExecutePermissions ( temp ) ; return temp ; }
Copies the source file to a file, replacing the @key.X@ tokens with the values from the data
context

@param script      source file path
@param dataContext input data context
@param framework   the framework
@param style       line ending style
@param destination destination file, or null to create a temp file

@return the token replaced temp file, or null if an error occurs.
@throws java.io.IOException on io error