Anyone care to help me out?

Discussion in 'Programming General' started by Fate1, Jun 8, 2008.

Anyone care to help me out?
  1. Unread #1 - Jun 8, 2008 at 5:05 PM
  2. Fate1
    Joined:
    Apr 21, 2005
    Posts:
    773
    Referrals:
    2
    Sythe Gold:
    5

    Fate1 Apprentice
    Banned

    Anyone care to help me out?

    Hi well I been trying to get this working for about 1 hour now. It is a login system, and you create an account and stuff, but I haven't programmed in a long time so I am getting use to java again and I know this isnt anything good but its for me to get warmed back up. Well here is my code.

    Code:
      }
        public void actionPerformed(ActionEvent e) {
        	Object source = e.getSource();
        	if (source == logOn) {
        		try {
        			BufferedReader readUsername = new BufferedReader(new FileReader("username.txt"));
        			String userName = readUsername.readLine();
        			readUsername.close();
        			try {
        				BufferedReader readPassword = new BufferedReader(new FileReader("password.txt"));
        				String passWord = readPassword.readLine();
        				readPassword.close();
        				if (userName.equals(username) && passWord.equals(password)) {
        					JOptionPane.showMessageDialog(this, "Log in Success!", "Success!", JOptionPane.INFORMATION_MESSAGE);
        				} else {
        					JOptionPane.showMessageDialog(this, "Invalid Username/Passowrd!", "Invalid!", JOptionPane.INFORMATION_MESSAGE);
        				}
        			} catch (IOException ioe) {
        			}
        		} catch (IOException ioe) {
        		}
        		return;
        	}
    My problem is everytime I try to logon I get invalid username and password no matter what I do. Even though in the username.txt and password.txt it is correct. Anyone care to help me fix this problem?

    Thanks.

    Fate

    EDIT: This is only part of the code.. not the whole thing!
     
  3. Unread #2 - Jun 8, 2008 at 6:29 PM
  4. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    Anyone care to help me out?

    try closing the files after you check them? most likly won't work but its worth a shot. :/


    and equalsIgnoreCase is another good thing to try and see if that makes it work instead of just equals... :/
     
  5. Unread #3 - Jun 8, 2008 at 7:40 PM
  6. Fate1
    Joined:
    Apr 21, 2005
    Posts:
    773
    Referrals:
    2
    Sythe Gold:
    5

    Fate1 Apprentice
    Banned

    Anyone care to help me out?

    Ah yeah! I totally forgot about equalsIgnoreCase, I'll go try it out right.

    EDIT: I tried it out, apparently it wont even compile with equalsIgnoreCase..

    EDIT2: I figured it out, had to add getText to username and password.
     
< auto wc program | [Help Needed] - Resources to learn VB. >

Users viewing this thread
1 guest


 
 
Adblock breaks this site