Wednesday, July 2, 2014

Java Hide Command Line Input

If you are asking the user to key in a password and wish to hide it while the user is typing it, the usual approach would not be able to support that.

The solution is to use the java.io.Console class. Other than the "readLine" method for the normal reading of input, it also has a "readPassword" method where nothing is shown as it is typed.

The only downside is that this cannot be used inside an IDE environment.

No comments:

Post a Comment