Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么我会丢失控制台输出?_Java_Eclipse_Stream - Fatal编程技术网

Java 为什么我会丢失控制台输出?

Java 为什么我会丢失控制台输出?,java,eclipse,stream,Java,Eclipse,Stream,我在JUnit测试中有以下代码: public class CvsCommandTest { ... @Test public void test() { PServerConnection con = new PServerConnection(root); GlobalOptions globalOptions = new GlobalOptions(); globalOptions.setCVSRoot(root.toStri

我在JUnit测试中有以下代码:

public class CvsCommandTest {
...
    @Test
    public void test() {
        PServerConnection con = new PServerConnection(root);
        GlobalOptions globalOptions = new GlobalOptions();
        globalOptions.setCVSRoot(root.toString());

        Client client = new Client(con, new StandardAdminHandler());
        client.setLocalPath(LOCAL_PATH);
        client.getEventManager().addCVSListener(new BasicListener());
        CheckoutCommand checkoutCmd = new CheckoutCommand();
        checkoutCmd.setBuilder(null);
        checkoutCmd.setModule("Outils");

        try {
            client.getConnection().open();
            LOG.info("CVS checkout : " + checkoutCmd.getCVSCommand());
            boolean successCheckout = client.executeCommand(checkoutCmd,globalOptions );
            LOG.info("Checkout COMPLETED : " + successCheckout);
...
调试时的输出为:

[信息]fr.package.CvsCommandTest-CVS签出:签出 -努蒂尔斯

cvs签出:更新Outils

第一行是我的日志,第二行来自侦听器,但我没有得到剩余的日志。 basicListener的定义如下:

import java.io.PrintStream;

import org.netbeans.lib.cvsclient.event.CVSAdapter;
import org.netbeans.lib.cvsclient.event.MessageEvent;

public class BasicListener extends CVSAdapter {

    /** * Stores a tagged line */
    private final StringBuffer taggedLine = new StringBuffer();

    /**
     * Called when the server wants to send a message to be displayed to the
     * user. The message is only for information purposes and clients can choose
     * to ignore these messages if they wish.
     * 
     * @param e
     *            the event
     */
    public void messageSent(MessageEvent e) {
        String line = e.getMessage();
        PrintStream stream = e.isError() ? System.err : System.out;
        if (e.isTagged()) {
            String message = MessageEvent.parseTaggedMessage(taggedLine, line);

            if (message != null) {
                stream.println(message);
            }
        } else {
            stream.println(line);
        }
        stream.close();
    }
}

我错过了什么?

把评论交上来回答

System.out-stream.close();-->晚安…

说明:

由于他在关闭
系统时使用
系统.out
输出他的日志消息。out
@请参阅
公共无效消息发送(MessageEvent e)
流.close()的结尾
System.out已关闭,无法再使用,因此祝
System.out晚安

解决方案是:

删除
流.close()命令

System.out-stream.close();-->晚安