62,614
社区成员
发帖
与我相关
我的任务
分享
else if (ae.getSource() == login) {
try {
FileInputStream fis = new FileInputStream("login.txt");
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader in = new BufferedReader(isr);
String str = null;
while (in.readLine() != null) {
str = in.readLine();
String username = str.split(" ")[0];
String password = str.split(" ")[1];
if (username.equals(tfname.getText())
&& password.equals(tfpassword.getText())) {
LauchWin lw = new LauchWin();
lw.lauchWin();
this.setVisible(false);
break;
} else {
System.out.print("error");
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
try {
FileInputStream fis = new FileInputStream("login.txt");
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader in = new BufferedReader(isr);
String str = null;
str = in.readLine();
while (str != null) {
String username = str.split(" ")[0];
String password = str.split(" ")[1];
if (!username.equals(tfname.getText())
&& !password.equals(tfpassword.getText())) {
// System.out.print("cannot match");
str = in.readLine();
} else if (username.equals(tfname.getText())
&& password.equals(tfpassword.getText())) {
in.close();
LauchWin lw = new LauchWin();
lw.lauchWin();
this.setVisible(false);
break;
}
}
if (username.equals(tfname.getText())
&& password.equals(tfpassword.getText())) {
LauchWin lw = new LauchWin();
lw.lauchWin();
this.setVisible(false);
break;
} else {
System.out.print("error");
break;
}
else if (ae.getSource() == login) {
try {
FileInputStream fis = new FileInputStream("login.txt");
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader in = new BufferedReader(isr);
String str = null;
while ((str = in.readLine()) != null) {
String username = str.split(" ")[0];
String password = str.split(" ")[1];
if (username.equals(tfname.getText())
&& password.equals(tfpassword.getText())) {
LauchWin lw = new LauchWin();
lw.lauchWin();
this.setVisible(false);
break;
} else {
System.out.print("error");
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
while ((str = in.readLine()) != null) //读第一次
str = in.readLine(); //又读了一次,所以str被赋予第二行的值。
while ((str = in.readLine()) != null)
str = in.readLine(); //不要,读了两次