需要在java中调用DOS命令配置路由不知怎么调用DOS命令 请知道的大侠们不吝赐教 最好有个简单的例子谢谢了

解决方案 »

  1.   


    package com.sxzl.test;public class TestRuntime {        public static void main(String args[]) { 
            try {         Process process = Runtime.getRuntime().exec( 
            //"cmd.exe /c start http://www.csdn.com/"//doc
            "C:\\Program Files\\Internet Explorer\\iexplore.exe"    
            +" http://www.csdn.com/"
            ); 
                    } catch (Exception e) { 
            e.printStackTrace(); 
            } 
            } 
            
    }
      

  2.   

    package com.sxzl.test;public class TestRuntime {        public static void main(String args[]) { 
            try {         Process process = Runtime.getRuntime().exec( 
            "cmd.exe /c start http://www.csdn.com/"//doc
            //"C:\\Program Files\\Internet Explorer\\iexplore.exe"    
            //+" http://www.csdn.com/"
            ); 
                    } catch (Exception e) { 
            e.printStackTrace(); 
            } 
            } 
            
    }
      

  3.   

    都可以,后面是doc前面是直接exe
      

  4.   

    public class Test { /**
     * @param args
     */
    public static void main(String[] args) {
    try {
    String[] cmd = new String[3];
    cmd[0 ] = "cmd";
    cmd[1] = "/C";
    cmd[2] = "d:/orgdemo.xml";
    Process p = Runtime.getRuntime().exec(cmd);
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }}
      

  5.   

    Runtime.getRuntime().exec("cmd.exe+命令") ;