• Post Reply Bookmark Topic Watch Topic
  • New Topic

accept a user value without echoing it.  RSS feed

 
garg sumit
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to accept an value from console without echoing it?
which means i want to receive an input in my program but don't want its user to have a look at what he/she is typing....
can any body tell me what inbuilt method can serve this purpose.....
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java1.6 introduces the Console class. It has a readPassword() method which does not echo the input. (be careful that System.getConsole() may return null).
 
Campbell Ritchie
Marshal
Posts: 56562
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the password method of the java.io.Console class, but remember that only works when your application is started from the command line.
There are PasswordField and JPasswordField classes in awt and Swing, which might help you.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Blue flag, blue flag, let me go
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!