What's the best way to call an external p开发者_StackOverflow中文版rogram (graphviz's dot in this case) from a Java program and grab the output?
You can use the Graphviz Java API class which is a wrapper for Runtime.exec(), this is if you have the dot binaries on the same server as your Java App.
If you don't have dot installed on the server or if you are using an environment like Google AppEngine where you can't install dot binaries locally then you can use Graphviz Server, a lightweight Java based HTTP server, you still need to install the dot binaries on the server on which you run Graphviz Server.
Runtime.exec() and ProcessBuilder do it.
You use one of them to create your process, then call its getInputStream
to get the output stream of the launched process.
精彩评论