I want to design a SIMPLE Java progeam to input a string (password) in its dotted form and display the same in its un-dotted form. Sample input: ***** (entered 12345) Sample output: 12345
Asked
Active
Viewed 74 times
0
-
1https://stackoverflow.com/questions/8138411/masking-password-input-from-the-console-java – NPE May 23 '18 at 19:06
1 Answers
1
Assuming this is a GUI system, You would want to use a PasswordField
in JavaFX or JPasswordField
in Swing.
This will allow you to type in the box and have the "Dotted" input.
You can then call .getText()
(returns a String
) for the PasswordField
, or call .getPassword()
for the JPasswordField
(returns a char[]
) to get the raw text values.
Alternatively, if you are using console, please see here for an answer

HamishD
- 349
- 2
- 15
-
I'm using blueJ. After getting the string in dots, will the same have the external interface of the dots or the internal interface too? – user9836598 May 23 '18 at 19:10
-
@user9836598 On the User interface, the values of the password field will remain dotted, but you can use the "non-dotted" values within your program as plain text(no dots). – HamishD May 23 '18 at 19:13