Buenas,
Si utilizas java 1.6 o superior, puedes hacer lo siguiente utilizando el objeto Console (
https://docs.oracle.com/javase/7/doc...Console.html):
Código Java:
Ver originalpublic void passwordExample() {
Console console
= System.
console(); if (console == null) {
System.
out.
println("Couldn't get Console instance"); }
console.printf("Testing password%n");
char passwordArray[] = console.readPassword("Enter your secret password: ");
console.
printf("Password entered was: %s%n",
new String(passwordArray
));
}
Un saludo