我正在尝试开发一个Java工具来重构css文件。我试图从Java访问命令提示符。命令提示符正常,但它没有运行csstidy exe文件。
try {
String command = "cmd /c start cmd.exe /K \"cd C:/Users/BS11040/Desktop/CSSTIDY_JAVA/";
Process child = Runtime.getRuntime().exec(command);
OutputStream out = child.getOutputStream();
out.write("csstidy.exe /r/n".getBytes());
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
答案 0 :(得分:0)
尝试直接调用你的.exe,你正在做复杂的事情:
String command = "C:/Users/BS11040/Desktop/CSSTIDY_JAVA/csstidy.exe";
Process child = Runtime.getRuntime().exec(command);
顺便说一句,CR和NEWLINE的代码是\n
和\r
,请注意使用正确的斜杠!