I have a program that the username and password are in a text file and the text file looks like this:
election:12345
and I have this code to read the file
try {
BufferedReader read=new BufferedReader(new FileReader("election_un_pass.txt"));
String line="";
while((line=read.readLine())!=null) {
String [] info=line.split(":");
if(info[0].matches(Login.uname) && info[1].matches(Login.pass)){
new Main();
} else {
JOptionPane.showMessageDialog(null, "Username or Password might not be correct");
}
Login.txtUName.setText("");
Login.txtPassword.setText("");
}
} catch (Exception e1) {
e1.printStackTrace();
}
Every time I run my program, even tho the username and password that I entered are correct, the Username or Password might not be correct
message will still appear and new Main()
won't appear.