java - 为什么我的命令提示符显示没有输入字符?
问题描述
当我执行我的程序并使用 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.
解决方案
在Windows环境下@echo off
,不显示,不提示也不显示输入的命令,只显示你输入的命令的输出;
Microsoft echo 命令的更多信息
推荐阅读
- postman - github Actions 上的自动邮递员测试因 ECONNREFUSED 而失败
- discord.js - 为什么discord找不到角色?
- javascript - 引导标签输入模板代码不起作用
- python - 如何使用curses输入后内联打印
- python - \1 (python) 的字符串替换
- python - Python - 在多个 for 循环之间未检测到 txt 文件
- azure - Azure App Service 使用服务总线队列消息,即使它已停止
- armadillo - 犰狳 + BLAS + LAPACK
- .net - 问:如何配置 cloudbuild.yaml 来运行测试?
- mysql - 如果输入为空,如何忽略枚举类型?