So I am trying to make a log in system which stores the usernames and password in a .txt file and when you log in it reads them and checks if the entered value and the value in the .txt file are matching. Unfortunately whenever i try to check is the input-ed value same as the value in the .txt file (is the entered username same as the username in the .txt file which I use as my database) i get a negative answer so here is the bugged part of the code:
public void actionPerformed(ActionEvent arg0) {
LineNumberReader LineReader = null;
try {
LineReader = new LineNumberReader(new FileReader("C:/Documents and Settings/Josip/Desktop/PROGRAMING MOTHAFUKAZ/JAVA/Login/DataBaza.txt"));
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String UserName = username.getText();
System.out.println(UserName);
try {
String Line = LineReader.readLine();
while(Line != null){
UserName = username.getText();
System.out.println(Line);
Line = LineReader.readLine();
if(Line == UserName){
System.out.println("LOGIN SUCCESFUL");
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
the username object is the JTextField