【发布时间】: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.
【问题讨论】: