Windows 7 cmd
在執行ping -n 5 127.0.0.1 > nul
時沒有問題。另外,Runtime.getRuntime.exec(new String[]{"ping", "-n", "5", "127.0.0.1"})
工作正常。命令在Windows cmd中工作但失敗,Runtime.getRuntime.exec()
但Runtime.getRuntime.exec(new String[]{"ping", "-n", "5", "127.0.0.1", ">", "nul"})
因Bad parameter >
而失敗。爲什麼?
我在Java6模式下使用Java7。
相關 - http://stackoverflow.com/questions/882772/capturing-stdout-when-calling-runtime-exec –