java中如何调用windows中的cmd程序,并且把cmd程序的输出记录下来

解决方案 »

  1.   

    process = Runtime.getRuntime().exec (command); InputStreamReader ir=newInputStreamReader(process.getInputStream()); 然后 对ir进行读取
      

  2.   

    String command = "cmd.exe /c start tracert" + target_name;
    process = Runtime.getRuntime().exec (command); 
    InputStreamReader ir=newInputStreamReader(process.getInputStream()); 然后 对ir进行读取