您可以
br.readLine()在线程中读取输入流(即)。这样,它始终在后台运行。
我们在应用程序中实现此方法的方式大致如下:
业务逻辑,即调用脚本的位置:
// Did something...Invokescript.execute("sh blah.sh"); // Invoke the background process here. The arguments are taken in processed and executed.// Continue doing what you were doingInvokescript.execute()将如下所示:
Invokescript.execute(String args) {// Process args, convert them to command array or whatever is comfortableProcess p = Runtime.getRuntime().exec(cmdArray);ReaderThread rt = new ReaderThread(p.getInputStream());rt.start();}ReaderThread应该继续读取您开始的过程的输出,只要它持续即可。
请注意,以上只是一个伪代码。



