を読んでいないだろう。BufferedReaderのは、私は、ユーザー名とパスワードがテキストファイルであり、テキストファイルは次のようになりますプログラム持って
election:12345
を、私は、ファイルを読むためにこのコードを持っている
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();
}
入力したユーザー名とパスワードが正しくても、プログラムを実行するたびにUsername or Password might not be correct
メッセージが表示され、new Main()
は表示されません。
一致していないと思われるLogin.unameとLogin.pass値を確認してください。 –
あなたは 'String.equals'を使いたくないのですか?そして、 'Login'の値は何ですか? – Marvin
@VuralAcarああ、実際には一致していて、Login.unameとLogin.passはtxtUName.getText()とtxtPassword.getText()に初期化されていますが、私はちょうどtxtUName.getText()とtxtPasswordを使用しました。 getText()。どうもありがとうございます!!!! – luh