I need to delete last character entered by user while entering password and I need help in handling Backspace pressed by user.
Below is the code I wrote for Login, how to modify it so that I can handle Backspace ?
void login(){
//As mentioned on internet
Console con=null;
con=System.console();
System.out.println("==============================================================");
System.out.println("\t\t\t LOGIN MENU\n");
System.out.print("\tEnter User Name: ");
String userName=scan.next();
System.out.print("\tEnter Your Password: ");
char[] password = con.readPassword("");
System.out.println(password);
System.out.println("==============================================================");
String pass=new String(password);
//Arrays.fill is used to fill 'spaces' to replace password (Security Concerns)
java.util.Arrays.fill(password, ' ');
//System.out.println(password);
con.flush();
}
Thank You! :)