private void ensureOutputDirectory(Path dir){
  if (!Files.exists(dir)) {
    try {
      Files.createDirectories(dir);
    }
 catch (    IOException e) {
      throw ShowMessageException.error("Error created output directory " + dir,null);
    }
  }
 else   if (!Files.isDirectory(dir))   throw ShowMessageException.error("Output directory " + dir + " is not a directory",null);
}

private void ensureOutputDirectory ( Path dir ) { if ( ! Files . exists ( dir ) ) { try { Files . createDirectories ( dir ) ; } catch ( IOException e ) { throw ShowMessageException . error ( "Error created output directory " + dir , null ) ; } } else if ( ! Files . isDirectory ( dir ) ) throw ShowMessageException . error ( "Output directory " + dir + " is not a directory" , null ) ; }
ensure output directory exists
