aspose file tools*
The moose likes Beginning Java and the fly likes Passwords not matching read using Console Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Passwords not matching read using Console" Watch "Passwords not matching read using Console" New topic
Author

Passwords not matching read using Console

Raman Ghai
Ranch Hand

Joined: Jan 01, 2012
Posts: 51
Hi there ,
I have created a program that stores and authenticates a user using a file .
Here is the code :


The passwords don't match even if I enter same passwords . How to solve this problem ?
Whenever a new user enters , the data overwrites the previous contents of the file , how to append ?
Can I use regex to compare here ? Any ideas will be appreciated ..thanks
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3932
    
  17

You twice made the assumption that a char[] is the same thing as a String. Its not:

In your store method you have the equivalent of:

You expect it to do create "my name:abc" but it won't, because char[] is not a String.

Second, in your verify method you have the equivalent of:

You expect that this would return true. But since a char[] is not the same as a String and so could never be equal.


Steve
Raman Ghai
Ranch Hand

Joined: Jan 01, 2012
Posts: 51
You twice made the assumption that a char[] is the same thing as a String. Its not:

Just to confirm

Output : false
Well , I need to find some other way out. Btw thanks for replying
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18113
    
    8

Well, there's a String constructor which accepts a char array, isn't there?
Raman Ghai
Ranch Hand

Joined: Jan 01, 2012
Posts: 51
Paul Clapham wrote:Well, there's a String constructor which accepts a char array, isn't there?

Yes, there is


//Calls

thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passwords not matching read using Console
 
Similar Threads
Trying to access an object's methods
how to encrypt a message using the string skipper
Dumping MySql database
how to split in java and remove certain lines from that text?
Strange Compiler Error