我遇到了代码问题。我需要从txtfile中读取数据。用户将输入他的用户名和密码,系统将检查存储在文本文件中的信息以进行验证,一旦成功,他将登录。但我有一个错误,我不知道如何继续。
public class existingCustomers {
String username, password;
public existingCustomers() {
Scanner input = new Scanner(System.in);
System.out.println("Welcome to Kreg Hotel booking System");
System.out.println("Please login.");
System.out.println("==============================================");
System.out.println("Username: ");
username = input.nextLine();
System.out.println("Password: ");
password = input.nextLine();
new userPassOk(username, password);
}
private boolean userPassOk(String user, String pass) throws FileNotFoundException {
Scanner s = new Scanner(new File("customerinfo.txt"));
username = user;
password = pass;
while (s.hasNextLine()) {
String[] userPass = s.nextLine().split(":");
if (userPass[0].equals(user) && userPass[1].equals(pass))
return true;
}
return false;
}
}
我的错误是
C:\Users\MegaStore\Desktop\java testing\existingCustomers.java:18: error: cannot find symbol
new userPassOk(username,password);
^
symbol: class userPassOk
location: class existingCustomers
1 error