通过Runtime.getRuntime().exec() 调用系统应用时,应该异步打印verbose信息
如果你这样打, 可能会导致执行阻塞 private static void printInput(Process p) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = in.readLine()) != null) { System.out.println(line); } in.close(); } 所以,你要用非阻塞的方式来打。CXF源代码里有个不错的例子: if (p.getErrorStream() != null) { StreamPrinter errorStreamPrinter = new StreamPrinter(p.getErrorStream(), "", System.out); errorStreamPrinter.start(); //StreamPrinter是一个线程 } if (p.getInputStream() != null) { StreamPrinter infoStreamPrinter = new StreamPrinter(p.getInputStream(), …
通过Runtime.getRuntime().exec() 调用系统应用时,应该异步打印verbose信息 Read More »