/** *  Java调用windows的DOS命令 *  实现调用Windows的ipconfig命令,然后将输出的信息通过IO流输出到控制台。 *  实现启动appium服务 *  实现关闭appium服务 */public class Doc {    public static void main(String[] args) throws Exception {         String cmd = "ping www.baidu.com";         String cmd1= "cmd /c appium";           String cmd2="taskkill /F /IM node.exe";         //         dosStartAndPrintResult(cmd2);//         Thread.sleep(5000);         dosStartAndPrintResult(cmd1);         Thread.sleep(3000);         dosStartAndPrintResult(cmd2);            }        /**传入一个命令,执行dos命令并回显*/    public static void dosStartAndPrintResult (String cmd){                try {            Runtime rt = Runtime.getRuntime(); // 获取运行时系统              Process proc = rt.exec(cmd);//执行命令            BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream(), Charset.forName("GBK")));//解决打印结果乱码的问题            //回显dos命令执行后的结果            String line = null;              while ((line = br.readLine()) != null) { // 打印出命令执行的结果                  System.out.println(line);              }          } catch (IOException e) {            e.printStackTrace();        }     }        }===================启动appium**执行结果===========================[Appium] Welcome to Appium v1.6.5[Appium] Appium REST http interface listener started on 0.0.0.0:4723===================ping百度**执行结果===========================正在 Ping www.a.shifen.com [220.181.112.244] 具有 32 字节的数据:来自 220.181.112.244 的回复: 字节=32 时间=2ms TTL=55来自 220.181.112.244 的回复: 字节=32 时间=2ms TTL=55来自 220.181.112.244 的回复: 字节=32 时间=4ms TTL=55来自 220.181.112.244 的回复: 字节=32 时间=1ms TTL=55220.181.112.244 的 Ping 统计信息:    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),往返行程的估计时间(以毫秒为单位):    最短 = 1ms,最长 = 4ms,平均 = 2ms    ===================关闭appium**执行结果===========================成功: 已终止进程 "node.exe",其 PID 为 42808。