[問題] 執行外部程式並重新導向的問題
大家好,假設我想執行 ipconfig 這個外部命令,並導向到另外一個檔案中。例如:
c:\ipconfig >ip.txt
但我在程式碼中這樣寫:
Process p = Runtime.getRuntime().exec("ipconfig >ip.txt");
為何這樣寫無法重新導向檔案呢?
一定要用 Process 的 outputstream 讀進來後再自己寫到檔案嗎?
這樣程式變的落落長@@,有變法直接用 OS 的 > 來做導向嗎?謝謝。
--
http://www.flickr.com/photos/mong0520/collections/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.32.30.33
推
09/07 00:22, , 1F
09/07 00:22, 1F