Reputation: 21
I want to take any input in Java without pressing the enter key. Actually I want to make a password input program, so that as soon as the user enter any character, I can clear the screen and replace the characters with an equal number of asterisks ("*"), like the typical password entries made anywhere in the web. Most importantly, I would like to do the same in the Java Terminal Window, not by using those applet methods. Please tell me if i would have to supply more details. I am using BlueJ.
Thank you, Mayank.
Upvotes: 2
Views: 2175
Reputation: 170158
You may want to have a look at the Console
's readPassword(...)
methods (needs Java 6+).
Or, when using Java 5 (or less), have a look at this article: Password Masking in the Java Programming Language, especially the paragraph Command-Line Input Masking.
Upvotes: 3