// if (summarydir != null) {
  // outputDir = summarydir;
  // }
  PrintStream outputStream = null;
  Writer overallsummary = null;
  Writer overallsummaryerrors = null;
  try {
      outputStream = getSummaryStream(summarydir,
        "Summary_" + querysetname + "_" + scenario_name, true); //$NON-NLS-1$
      
      overallsummary = getOverallSummaryStream(summarydir);
      overallsummaryerrors = getOverallSummaryErrorsStream(summarydir);
  } catch (IOException e) {
      e.printStackTrace();
      //              logError("Unable to get output stream for file: " + outputFileName); //$NON-NLS-1$
      throw e;
  }
  outputStream
    .println("Scenario " + scenario_name + " Summary [" + this.resultMode + "]"); //$NON-NLS-1$
  outputStream.println("Query Set Name " + querysetname); //$NON-NLS-1$
  outputStream.println("=================="); //$NON-NLS-1$
  outputStream.println("Number of Test Query Sets: " + total_querysets); //$NON-NLS-1$ //$NON-NLS-2$
  outputStream.println("=================="); //$NON-NLS-1$
  outputStream.println("Test Query Set"); //$NON-NLS-1$
  outputStream
    .println("\t" + "Name" + "\t\t\t\t" + "Pass" + "\t" + "Fail" + "\t" + "Total" + "\t" + "Time(sec)"); //$NON-NLS-1$
  if (!this.query_sets.isEmpty()) {
      // sort so that like failed queries are show together
      Collections.sort(this.query_sets);
      
      for (Iterator<String> it = this.query_sets.iterator(); it.hasNext();) {
    outputStream.println(it.next()); //$NON-NLS-1$ //$NON-NLS-2$
      }
  }
  outputStream.println("=================="); //$NON-NLS-1$
  outputStream.println("\t" + "Totals" + "\t\t\t\t" + total_pass + "\t"
    + total_fail + "\t" + total_queries + "\t" + total_seconds
    / 1000);
  
  
  try {
      overallsummary.write( pad(scenario_name, 30, ' ') + " \t" + total_pass + "\t" + total_fail + "\t" + total_queries + "\n");
      overallsummary.flush();
  } catch (IOException ioe) {
      ioe.printStackTrace();
  } finally {                       // always close the file
      try {
    overallsummary.close();
      } catch (IOException ioe2) {
      // just ignore it
      }
  } // 
  // outputStream
  //      .println("Number of Queries: " + total_queries); //$NON-NLS-1$ //$NON-NLS-2$
  // outputStream
  //      .println("Number Passed    : " + total_pass); //$NON-NLS-1$ //$NON-NLS-2$
  // outputStream
  //      .println("Number Failed    : " + total_fail); //$NON-NLS-1$ //$NON-NLS-2$
  if (!this.failed_queries.isEmpty()) {
      // sort so that like failed queries are show together
      Collections.sort(this.failed_queries);
      outputStream.println("\n\n=================="); //$NON-NLS-1$
      outputStream.println("Failed Queries"); //$NON-NLS-1$  
      
      overallsummaryerrors.write("\n" + scenario_name + "\n");
      for (Iterator<String> it = this.failed_queries.iterator(); it
        .hasNext();) {
    String error = it.next();
    outputStream.println("\t - " + error); //$NON-NLS-1$ //$NON-NLS-2$
    // write all errors to the summary file
    overallsummaryerrors.write("\t\t" + error + "\n");
      }
      
    try {
        overallsummaryerrors.flush();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    } finally {                       // always close the file
        try {
      overallsummaryerrors.close();
        } catch (IOException ioe2) {
        // just ignore it
        }
    } //