Here you can find the source of executeDotCommand(final File dotFile)
Parameter | Description |
---|---|
dotFile | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
InterruptedException | an exception |
private static File executeDotCommand(final File dotFile) throws IOException, InterruptedException
//package com.java2s; /*//from w w w. j av a2s . c o m * Copyright 2012 jccastrejon * * This file is part of ExSchema. * * ExSchema is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * ExSchema is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with ExSchema. If not, see <http://www.gnu.org/licenses/>. */ import java.io.File; import java.io.IOException; public class Main { /** * Execute Graphviz dot's command to generate the pdf file. * * @param dotFile * @throws IOException * @throws InterruptedException */ private static File executeDotCommand(final File dotFile) throws IOException, InterruptedException { Process process; int processCode; File returnValue; String dotCommand; returnValue = new File(dotFile.getParent(), "schemas.pdf"); dotCommand = "dot -Tpdf " + dotFile.getAbsolutePath() + " -o " + returnValue.getAbsolutePath(); process = Runtime.getRuntime().exec(dotCommand); processCode = process.waitFor(); dotFile.delete(); if (processCode != 0) { throw new RuntimeException("An error ocurred while executing: " + dotCommand); } return returnValue; } }