-3

I want to check if filename and password file correct continue code.. else get an error for check password file.

my code is:

Scanner scanInputUser = new Scanner(System.in);
        System.out.println("Please Enter UserName:");
        String fileName = scanInputUser.nextLine();

 fileHandler.setUserName(fileName); // This file name has already been defined in another class.
//and using this method with instance class..


        try {
            System.out.println("Please Enter Password:");
            String passSaver = scanInputUser.nextLine();
            cryptography.setKeyUser(passSaver); // password decrypt save to same file. 
//This method has already been defined in another class.

            fileHandler.passwordSaver(passSaver); 

        } catch (Exception e) {
            e.printStackTrace();
        }

//TODO check correct password for file name
(note: password file name saved to the same file).
Daniella
  • 1
  • 2
  • 1
    And I want a pony. Now what is your question? – Joe C Mar 12 '17 at 07:37
  • We are a question-and-answer site, not a coders-for-hire service. Please narrow your question down to a specific problem that would be on-topic for this site. See: [Why is "Can someone help me?" not an actual question?](http://meta.stackoverflow.com/q/284236) and [How to ask a good question when I'm not sure what I'm looking for?](https://meta.stackoverflow.com/questions/262527/how-to-ask-a-good-question-when-im-not-sure-what-im-looking-for) – Joe C Mar 12 '17 at 07:41

1 Answers1

-1

You are probably looking for equals(Object o) (Oracle Doc) though I can't be sure from your description of the problem.

Short example:

if (passSaver.equals(passPhrase)) {
    dostuff();
}

Also see: How do I compare strings in Java?

Community
  • 1
  • 1
showp1984
  • 378
  • 1
  • 2
  • 13
  • Not quite sure why there is a no-comment down vote on my answer. I gave a short and concise answer with an example from what I could understand as the question. I didn't provide a coding-service (wrote the whole answer in code) and I gave two pointers to locations with a lot more information on this topic. – showp1984 Mar 12 '17 at 13:04