Java runtime.getruntime()从执行命令行程序获得输出
Runtime rt = Runtime.getRuntime();String[] commands = {"system.exe" , "-send" , argument};Process proc = rt.exec(commands);System.out.print(proc);
String[] commands = {"system.exe","-get t"};Process proc = rt.exec(commands);InputStream stdin = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(stdin);BufferedReader br = new BufferedReader(isr);String line = null;
System.out.println("<OUTPUT>");while ( (line = br.readLine()) != null)
System.out.println(line);System.out.println("</OUTPUT>");int exitVal = proc.waitFor();
System.out.println("Process exitValue: " + exitVal);
慕村9548890
冉冉说
回首忆惘然
一只斗牛犬
随时随地看视频慕课网APP
相关分类