将 java 更新到最新版本 7u25 后,runtime.getruntime().exec 不能再工作了。
//jhghai_w.filepath = "C:\\aucs\\data\\tmp.txt";
br = new BufferedReader(new InputStreamReader(Runtime.getRuntime()
.exec("CMD.EXE /C \"C:\\Program Files\\juman\\juman.exe \" -e < "+jhghai_w.filepath)
.getInputStream()));
我已经阅读了参考资料:JDK 7u25:由 Runtime.exec 更改引起的问题的解决方案 https://blogs.oracle.com/thejavatutorials/entry/changes_to_runtime_exec_problems
并尝试了一些修改如下:
br = new BufferedReader(new InputStreamReader(Runtime.getRuntime()
.exec("CMD.EXE /C \"C:\\Program Files\\juman\\juman.exe -e < \""+jhghai_w.filepath)
.getInputStream()));
和这个:
br = new BufferedReader(new InputStreamReader(Runtime.getRuntime()
.exec(new String[] {"cmd","/C" "C:\\Program Files\\juman\\juman.exe"-e < ",jhghai_w.filepath})
.getInputStream()));
和这个:
br = new BufferedReader(new InputStreamReader(Runtime.getRuntime()
.exec(new String[] {"cmd","/C" "C:\\Program Files\\juman\\juman.exe","-e“,”<",jhghai_w.filepath})
.getInputStream()));
和这个:
br = new BufferedReader(new InputStreamReader(Runtime.getRuntime()
.exec(new String[] {"cmd","/C" "\"C:\\Program Files\\juman\\juman.exe"","\"-e < \"",jhghai_w.filepath})
.getInputStream()));
我什至直接将“jhghai_w.filepath”替换为“C:\aucs\data\tmp.txt”。但是这些都不起作用。我的修改有什么问题?