/** * java calls the Windows DOS command * implements the ipconfig command that invokes windows, and then outputs the output information to the console via IO stream. * Implement start Appium service * implement close Appium service */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 ( dosstartandprintresult (CMD1); &nbSp; thread.sleep ( dosstartandprintresult) (CMD2) ; } /** passes in a command, executes a DOS command, and echoes back */ public static void dosstartandprintresult (String cmd) { try { runtime rt = runtime.getruntime (); // Get runtime system process proc = rt.exec (cmd);//execute command bufferedreader br = new bufferedreader (New inputstreamreader (Proc.getinputstream (), charset.forname ("GBK"));// Solve the problem of garbled printing results //echo DOS command results after execution String line = null; while ((Line = br.readline ()) != null) { // Print out the results of the command execution system.out.println (line); } } catch (ioexception e ) { e.printstacktrace (); } } }=================== start appium** Execution Results ===========================[appium] welcome to appium v1.6.5[appium]  appium rest http interface listener started on 0.0.0.0:4723================ ===ping Baidu * * Implementation Results =========================== is Ping www.a.shifen.com [220.181.112.244] has 32 bytes of data: Reply from 220.181.112.244 : byte =32 time =2ms ttl=55 from 220.181.112.244 reply: byte =32 time =2ms ttl=55 reply from 220.181.112.244 : bytes =32 Time =4ms ttl=55 from 220.181.112.244 reply: byte =32 time =1ms ttl=55220.181.112.244 Ping Statistics: Packet: sent = 4, received = 4, lost = 0 (0% lost), estimated time to round trip (in milliseconds): shortest = 1ms, longest = 4ms, average = 2ms =================== shutdown appium** Execution result =========================== successful: terminated process "Node.exe", its PID is 42808.
Java----invoke DOS command for Windows and Echo/start and close Appium