• Post Reply Bookmark Topic Watch Topic
  • New Topic

getPassword() and 'echoing' character

 
martin klima
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I have the following problem. I would like to write a simple method, something like - String getPassword(char echo) - for reading a password from keyboard. And, as usually, not to show the characters typed by user, but an 'echoing' character.
The output should look like this:
Enter your password: *********
no like this:
Enter your password: qwer345re
Can somebody help me? Thank you in advance.
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java is designed to be cross-platform and some of those platforms may not even have consoles (think phones or Java Rings) so the console support is pretty weak. You cannot change the echo character on the console, though there are GUI classes that provide that functionality.
If you REALLY need this functionality and are on a Windows platform I created a JNI layer to do exactly what you want, but you'd have to install a DLL on the client.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!