我编写了一个简单的程序,它从控制台获取用户的输入,然后将其打印出来。但是当用户输入时,它会请求第二个用户输入,并且只读取第二个输入。
Code:
fun main(args: Array<String>) {
print("Enter text: ")
val stringInput = readLine()!!
println("Readed text: $stringInput")
}
Console:
> Task :MainKt.main()
Enter text: FirstInput
SecondInput
Disconnected from the target VM, address: 'localhost:37282', transport: 'socket'
Connected to the target VM, address: '127.0.0.1:37264', transport: 'socket'
Readed text: SecondInput
我正在使用最新版本的 IntelliJ IDEA。我不知道为什么会发生这种情况。我正在使用 Windows。
这似乎是 IntelliJ 内部控制台中的一个错误:请参阅这张票 https://youtrack.jetbrains.com/issue/KTIJ-673(通过发现这个答案 https://stackoverflow.com/a/65184427/10134209).
(同样的问题似乎也出现在后面这个问题 https://stackoverflow.com/questions/65100768/readline-only-reads-second-input-in-console and 这个问题 https://stackoverflow.com/questions/65019899/problem-with-kotlin-readline-function-using-intellij-internal-console.)
我不知道它是否指的是同样的问题,但是这个答案 https://stackoverflow.com/a/65001965/10134209建议更改“编辑配置”菜单中的 JRE 选项,然后再次将其更改回来。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)