标签:
使用管道方式,也可以使用Logoutputstream。下面是管道方式例子。跟C语言类似。
PipedOutputStream outputStream = new PipedOutputStream();
PipedInputStream inputStream = new PipedInputStream(outputStream);
CommandLine commandline = CommandLine.parse("java -jar C:\\Output7.jar");
DefaultExecutor exec = new DefaultExecutor();
PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream);
exec.setStreamHandler(streamHandler);
exec.execute(commandline, new DefaultExecuteResultHandler());
new DefaultExecuteResultHandler()用于异步。
PipedInputStream inputStream = new PipedInputStream(outputStream)用于处理子进程输出。
标签:
原文地址:http://blog.csdn.net/wwx051312/article/details/43331113