private void generateCode(VelocityEngine ve,String templateDir,File file,VelocityContext context){
  Template tm=ve.getTemplate(templateDir + File.separator + PIPELINE_TEMPLATE);
  StringWriter sw=new StringWriter();
  tm.merge(context,sw);
  try (PrintWriter writer=new PrintWriter(file.getAbsolutePath(),"UTF-8")){
    writer.println(sw);
  }
 catch (  UnsupportedEncodingException|FileNotFoundException e) {
    logger.log(Level.SEVERE,"Unable to write to file",e);
  }
}

private void generateCode ( VelocityEngine ve , String templateDir , File file , VelocityContext context ) { Template tm = ve . getTemplate ( templateDir + File . separator + PIPELINE_TEMPLATE ) ; StringWriter sw = new StringWriter ( ) ; tm . merge ( context , sw ) ; try ( PrintWriter writer = new PrintWriter ( file . getAbsolutePath ( ) , "UTF-8" ) ) { writer . println ( sw ) ; } catch ( UnsupportedEncodingException | FileNotFoundException e ) { logger . log ( Level . SEVERE , "Unable to write to file" , e ) ; } }
creates a file and generates code in it using templates .
