Java 如何将2个命令的内容附加到1个控制台中

Java 如何将2个命令的内容附加到1个控制台中,java,eclipse,eclipse-plugin,Java,Eclipse,Eclipse Plugin,我的程序需要运行2个命令。第二个命令将基于上一个命令的结果运行 有人建议我使用IStreamListener来获取第一个命令的结果,并检查运行第二个命令的条件,但输出分为两个控制台输出 我的代码在这里 String[] cmdLine = buildCommandLine(configuration, true); Process process = DebugPlugin.exec(cmdLine, null, null); IProcess newProcess = DebugPlugin.

我的程序需要运行2个命令。第二个命令将基于上一个命令的结果运行

有人建议我使用IStreamListener来获取第一个命令的结果,并检查运行第二个命令的条件,但输出分为两个控制台输出

我的代码在这里

String[] cmdLine = buildCommandLine(configuration, true);
Process process = DebugPlugin.exec(cmdLine, null, null);
IProcess newProcess = DebugPlugin.newProcess(launch, process, "", null);

IStreamsProxy streamsProxy = newProcess.getStreamsProxy();
IStreamMonitor streamMonitor = streamsProxy.getOutputStreamMonitor();

isProcessSuccess = true;
streamMonitor.addListener(new IStreamListener() {

    @Override
    public void streamAppended(String text, IStreamMonitor monitor) {
        if (text.contains("[ERROR]")) {
            isProcessSuccess = false;
        }
    }
} );

if (isProcessSuccess) {
    String[] cmdLine2 = buildCommandLine(configuration, false);
    Process process2 = DebugPlugin.exec(cmdLine2, null, null);
    IProcess newProcess2 = DebugPlugin.newProcess(launch, process2, "", null);
}

如何将两个命令的内容附加到一个控制台?

那么问题出在哪里?@Andy:我想第二个命令的结果会输出到第一个命令控制台。这将有助于我轻松查看结果,因为我将启动许多配置,每个配置将包含上面的2个命令