title: How to make a Login with a txt file in java
body: <p>I am trying to develop a login using a txt file My problem is at <code>if (Authenticator.equals(un+" "+pw))</code> it is not coming through true and is moving to my else statement. Why is my statement not  true? I know its checking only the first line..... suggestions anyone? <img src="https://i.stack.imgur.com/D7Ael.jpg" alt="what I have in the note pad and the printed results"></p>
  
  <pre><code>private void SubmitActionPerformed(java.awt.event.ActionEvent evt) {                                       
                  String un = UserName.getText().trim();
                  String pw = Password.getText().trim();
              try {
                  Scanner Scan = new Scanner(new File("Login.txt"));            
                  System.out.println(Scan.nextLine().trim());
                  String Authenticator = Scan.nextLine().trim();
                      if (Authenticator.equals(un+" "+pw)){
                      System.out.println("sweetness");
                      } else {
                          System.out.println("bummer");
                      }
                  }catch (Exception ex) {
                      ex.printStackTrace();
                  }
              System.out.println(un+" "+pw);                 
          }
  </code></pre>