/**
  * Blocking method that saves (if required) a finished workflow runs output.
  *
  * <p>Blocks until the workflow run has finished. Works even if the workflow result was not 0. The
  * first time this method is called it saves the output to file.
  *
  * @return Output of this class including parameters passed to the bat.script and a capture of
  *     anything that sends to output or error streams. Does not include the results of the
  *     workflow run use getOutputFile() for these.
  * @throws TavernaException Thrown if there is an InterruptedException, ProcessException or error
  *     saving the output.
  * @throws ProcessException If the process was not started.
  */
 public String getOutput() throws TavernaException, ProcessException {
   if (outputFile == null) {
     return saveOutput();
   }
   try {
     return runner.getOutput();
   } catch (InterruptedException ex) {
     throw new TavernaException("Workflow was interrupted.", ex);
   }
 }
 private String saveOutput() throws TavernaException, ProcessException {
   String output = null;
   FileWriter writer = null;
   try {
     output = runner.getOutput();
     outputFile = new File(runDirectory, "Output.txt");
     writer = new FileWriter(outputFile);
     writer.write(output);
     writer.close();
   } catch (InterruptedException ex) {
     throw new TavernaException("Workflow was interrupted.", ex);
   } catch (IOException ex) {
     throw new TavernaException("Workflow output could not be saved.", ex);
   } finally {
     try {
       if (writer != null) {
         writer.close();
       }
     } catch (IOException ex) {
       throw new TavernaException("Workflow output could not be saved.", ex);
     }
   }
   return output;
 }