gpt4 book ai didi

java - 为什么我的命令提示符显示未输入任何字符?

转载 作者:太空宇宙 更新时间:2023-11-04 09:18:40 25 4
gpt4 key购买 nike

当我执行程序并使用 jline 的 ConsoleReader 或 BufferedReader 读取时,我输入的文本会被输入但不会显示。例如,我输入 asd,我的控制台不显示 asd,但是当我按 Enter 键时,它告诉我无法找到命令“asd”。输入“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.

最佳答案

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

更多信息请访问 Microsoft echo command

关于java - 为什么我的命令提示符显示未输入任何字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58640834/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com