java 调用dos命令行
我想用java执行phantomjs,但是发现我写的不行,
public static void invokeCmd() {
try {
// Execute command
String command = "cmd /c start cmd.exe";
Process child = Runtime.getRuntime().exec(command);
// Get output stream to write from it
OutputStream out = child.getOutputStream();
out.write("cd C:\\phantomjs-1.9.2-windows /r/n".getBytes());
out.flush();
out.write("phantomjs.exe nova.js http://www.amcharts.com/fiddle/?id=amcharts/tZyTN /r/n"
.getBytes());
out.close();
} catch (IOException e) {
}
}
String command = "cmd /c start d:qq.txt";
Process child = Runtime.getRuntime().exec(command);
Runtime.getRuntime().exec("cmd.exe /c start http://www.amcharts.com/fiddle/?id=amcharts/tZyTN");