Home > Back-end >  Java to create the user interface, read TXT file for user and password authentication
Java to create the user interface, read TXT file for user and password authentication

Time:09-18

Database system requirements to build a TXT file, each row 12 digits, before six is the user name, after six is the corresponding password, want to use Java to create a user login authentication password is correct, a bit not Java, strives for the complete package

CodePudding user response:

String account="111111";
String password="111111";
Map The map=new HashMap (a);
String path="D: \ \ test. TXT".
The File File=new File (path);
BufferedReader bReader=new BufferedReader (new FileReader (file));
String String="";
String PC []=null;
The String key="";
String valuehttps://bbs.csdn.net/topics/="";
While ((string=bReader readLine ())!=null) {
PC=string. The split (", ");
Key=PC [0];
Value=https://bbs.csdn.net/topics/pc [1];
The map. The put (key, value);
}
Set KeySet=map. The keySet ();
For (String string2: keySet) {
System. The out. Println (string2);//account
System. The out. Println (map. Get (string2));//password
If (the equals (string2) & amp; & Password. Equals (map. Get (string2))) {
System. The out. Println (" password is right ");
break;
} else {
System. The out. Println (" password error ");
}
}
BReader. Close ();
//TXT text, password and account between commas in English

CodePudding user response:

String account="111111";
String password="111111";
Map The map=new HashMap (a);
String path="D: \ \ test. TXT".
The File File=new File (path);
BufferedReader bReader=new BufferedReader (new FileReader (file));
String String="";
String PC []=null;
The String key="";
String valuehttps://bbs.csdn.net/topics/="";
@ SuppressWarnings (" unused ")
boolean result=false;
While ((string=bReader readLine ())!=null) {
PC=string. The split (", ");
Key=PC [0];
Value=https://bbs.csdn.net/topics/pc [1];
The map. The put (key, value);
}
Set KeySet=map. The keySet ();
For (String string2: keySet) {
System. The out. Println (string2);//account
System. The out. Println (map. Get (string2));//password
If (the equals (string2) & amp; & Password. Equals (map. Get (string2))) {
Result=true;
break;
}
}
If (result=false) {
System. The out. Println (" password error ");
} else {
System. The out. Println (" password is right ");
}
BReader. Close ();
Just that a bit of a problem, change it

CodePudding user response:

CodePudding user response:

Learning is very good,

CodePudding user response:

Kiss me no matter lose don't lose the password directly success?? Don't act for than

CodePudding user response:

3 # more problems
The==comparison
=assignment
  • Related