Adblock breaks this site

Anyone care to help me out?

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

  1. Fate1

    Fate1 Apprentice
    Banned

    Joined:
    Apr 21, 2005
    Posts:
    773
    Referrals:
    2
    Sythe Gold:
    5
    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!
     
  2. SuF

    SuF Legend
    Pirate Retired Global Moderator

    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
    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... :/
     
  3. Fate1

    Fate1 Apprentice
    Banned

    Joined:
    Apr 21, 2005
    Posts:
    773
    Referrals:
    2
    Sythe Gold:
    5
    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. >


 
 
Adblock breaks this site