[英]Running csstidy from Java
I am trying to develop a Java tool to refactor css files. 我正在尝试开发Java工具来重构CSS文件。 I am trying to access the command prompt from Java.
我正在尝试从Java访问命令提示符。 The command prompt is opening fine but it's not running the csstidy exe file.
命令提示符打开正常,但未运行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();
}
Try invoking your .exe directly, you are doing it way to complicated: 尝试直接调用您的.exe,这样做很复杂:
String command = "C:/Users/BS11040/Desktop/CSSTIDY_JAVA/csstidy.exe";
Process child = Runtime.getRuntime().exec(command);
And by the way, the codes for CR and NEWLINE are \\n
and \\r
, take care to use the right slash! 顺便说一下,CR和NEWLINE的代码是
\\n
和\\r
,请注意使用正确的斜杠!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.