Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert the output of PinField.getPassword() to string

        if ("Submit".equals(cmd)) { //Process the password.
    String UserNameInput=UserName.getText();
    ///////////////////////////////ERROR Pin when printed shows error/////////////////////////////
    char[] PinInput = PinField.getPassword();
    String pinInput=PinInput.toString();
            //for debugging , print PinInput , but it prints garbage
    System.out.println("Pin entered is "+PinInput);
            //pinInput has garabage instead of the Pin that was entered
            //so the function isPasswordCorrect fails to verify UserName & Pin
    if (isPasswordCorrect(UserNameInput,pinInput)) 
              {
               //some tasks
              }
         }
            boolean isPasswordCorrect(String Username,String Pin)
            {
             //verify username & pin 
            }

I need to convert the PinInput from character array to String, so that I can use the function isPasswordCorrect() . When I use toString() method , it produces garbage value , what should I do to convert the value of PinInput to String ?

like image 746
Gaurav Avatar asked Dec 29 '22 09:12

Gaurav


1 Answers

Look at the String API, there is a constructor that accepts a char array.

like image 50
camickr Avatar answered Jan 09 '23 11:01

camickr