感谢您的关注。
我创建了一个程序,我正在使用登录表单和注册表单。一旦用户注册了他们的电子邮件,他们的密码将被保存到 submit.txt
中。然后他们将返回登录表单并输入保存到 submit.txt
中的电子邮件和密码。
在我的代码中,我对注册表单使用写入文件,对登录表单使用读取文件。但是,它不起作用。我在用于读取文件的代码中知道我的问题。你能帮我意识到这一点吗?
非常感谢您的帮助。
if (checkPassword(usern, hash)) {
System.out.println("Logged in!");
ChooseWindow ptb = new ChooseWindow();
ptb.setVisible(true);
LoginWindow.this.dispose();
} else {
System.out.println("Wrong password");
}
public boolean checkPassword(String username, String pass) {
try {
FileReader inFile = new FileReader("/users/Ender/Desktop/GetUser/submit.txt");
BufferedReader inStream = new BufferedReader(inFile);
String inString;
while ((inString = inStream.readLine()) != null) {}
inStream.close();
}catch (IOException e) {
e.printStackTrace();
}
return false;
}
原文由 Ender phan 发布,翻译遵循 CC BY-SA 4.0 许可协议
这是我从文件中读取的代码: