Reputation: 507
Hi i want to pass username and password as a command line argument and i am able to do that but my problem is when i entered password it get displayed on command line. I want to display in ***** format.
Upvotes: 1
Views: 945
Reputation: 520
Depending on your console, the following code will get the Console object and will take input while masking the console echo.
Console console = System.console();
char password[] = console.readPassword("Enter password: ");
console.printf("You entered: %s%n", new String(password));
Note that if you are using an IDE with a built-in console (IE Eclipse), this may not work.
Upvotes: 1