private void injectContent(Inject injectContent) throws IOException, MojoExecutionException {
  Map<Pattern,File> contents=getContentsMap(injectContent.getContents());
  File tmpFile=ioFactory.createTemporaryFile(injectContent.getDestinationFile());
  BufferedReader reader=null;
  BufferedWriter writer=null;
  try {
    reader=ioFactory.newReader(injectContent.getDestinationFile());
    writer=ioFactory.newWriter(tmpFile);
    String line;
    while ((line=reader.readLine()) != null) {
      File content=doesLineMatchId(contents,line);
      if (content != null) {
        ioFactory.writeContent(writer,content,getContentConverter(injectContent));
      }
 else {
        ioFactory.writeLine(writer,line);
      }
    }
  }
  finally {
    if (reader != null) {
      reader.close();
    }
    if (writer != null) {
      writer.flush();
      writer.close();
    }
  }
  ioFactory.moveTo(tmpFile,injectContent.getDestinationFile());
}

private void injectContent ( Inject injectContent ) throws IOException , MojoExecutionException { Map < Pattern , File > contents = getContentsMap ( injectContent . getContents ( ) ) ; File tmpFile = ioFactory . createTemporaryFile ( injectContent . getDestinationFile ( ) ) ; BufferedReader reader = null ; BufferedWriter writer = null ; try { reader = ioFactory . newReader ( injectContent . getDestinationFile ( ) ) ; writer = ioFactory . newWriter ( tmpFile ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { File content = doesLineMatchId ( contents , line ) ; if ( content != null ) { ioFactory . writeContent ( writer , content , getContentConverter ( injectContent ) ) ; } else { ioFactory . writeLine ( writer , line ) ; } } } finally { if ( reader != null ) { reader . close ( ) ; } if ( writer != null ) { writer . flush ( ) ; writer . close ( ) ; } } ioFactory . moveTo ( tmpFile , injectContent . getDestinationFile ( ) ) ; }
injects the configured content files into the destination file .
