In Java the System
static method console()
returns the object allowing to read from terminal. The Console
instance returned by that method provides method readLine()
and readPassword()
. First one echoing input to the console, but second -- doesn't.
In KotlinJVM application provides top level function readLine()
to read input from the console, but there is no one to readPassword()
. Also the System.console()
returns null.
How I can read password (without echoing) from KotlinJVM application?
I just tried these and got NPE
package com.helpchoice.kotlin.fuel.dsl
fun main(args: Array<String>) {
try {
System.console().readPassword("pw:")
} catch (e: Throwable) {
println(e::class.java.name)
}
}