【问题标题】:Why does my command prompt show no characters entered?为什么我的命令提示符显示没有输入字符?
【发布时间】:2020-02-26 15:57:41
【问题描述】:

当我执行我的程序并使用 jline 的 ConsoleReader 或 BufferedReader 读取时,我输入的文本已输入但未显示。例如我输入asd,我的控制台没有显示asd,但是当我按回车时,它告诉我Could not find command 'asd'. Type 'help' for help 所以我输入的字符串被读取了,但没有显示出来。

Windows 命令提示符,启动脚本:

@echo off
java -jar PixelCloud.jar
pause

我尝试将我的代码放在一个线程中,使用 Scanner,使用 BufferedReader,使用 ConsoleReader,但没有任何工作

        AnsiConsole.systemInstall();
        try {
            reader = new ConsoleReader(System.in, System.out);
        } catch (IOException e) {
            e.printStackTrace();
        }
        console = new ColoredConsole();
        console.sendMessage(Message.TYPE_HELP);
        String line;
        System.out.println("test");
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while((line = reader.readLine()) != null) {
            System.out.println("test2");
            Command.dispatchCommand(line);
        }

我希望当我输入 asd 时,asd 在我输入时会显示出来。 我当前的控制台输出是

Type "help" for help.
test
test2
Could not find command 's'. Type "help" for help.
test2
Could not find command 'hello'. Type "help" for help.

【问题讨论】:

    标签: java jline


    【解决方案1】:

    在Windows环境下,@echo off,不显示提示,也不显示输入的命令,只显示你输入的命令的输出;

    更多信息Microsoft echo command

    【讨论】:

    • @echo off 只是关闭批处理文件的消息,而不是输入。我试过了,尽管如此,但没有用(对不起我的英语不好)
    猜你喜欢
    • 2021-06-30
    • 2021-07-30
    • 2015-08-23
    • 1970-01-01
    • 2017-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多