Ejemplo n.º 1
0
  public static void doConvert(String fileName, String format, String outputfilename) {
    File file = new File(fileName);
    if (!file.exists()) {
      printToConsole("File '" + file.getAbsolutePath() + "' not found.");
      return;
    }
    DiagramHandler handler = new DiagramHandler(file);
    if (outputfilename == null) {
      if (fileName.contains("." + Program.EXTENSION))
        fileName = fileName.substring(0, fileName.indexOf("." + Program.EXTENSION));
      outputfilename = fileName + "." + format;
    } else if (!outputfilename.endsWith("." + format)) outputfilename += "." + format;

    try {
      if (format != null) handler.getFileHandler().doExportAs(format, new File(outputfilename));
      printToConsole("Conversion finished");
    } catch (Exception e) {
      printUsage();
    }
  }