code: public void closeReport( Report report ) throws IOException, URISyntaxException {
          FileWriter out = null;
          try
          {
              File reportFile = new File( reportsDirectory, outputNameOf( report ) );
              String documentUri = report.getDocumentUri();
              if (documentUri != null) {
                  if (reportFile.equals(new File(new URI(documentUri)))) {
                      reportFile = new File(reportFile.getAbsolutePath() + ".out");
                  }
              }
              IOUtil.createDirectoryTree( reportFile.getParentFile() );
              StringWriter strOut = new StringWriter();
              report.printTo( strOut );
              strOut.flush();
              out = new FileWriter( reportFile );
              String reportString = strOut.toString();
              LOGGER.trace("Final Report to be written :\n {}", reportString);
              IOUtils.write(reportString, out);
              out.flush();
          }
          finally
          {
              IOUtil.closeQuietly( out );
          }
      }
docs: {@inheritDoc}