java创建用户界面,读取txt文件,进行用户和密码验证 数据库系统作业要求先自己建一个txt文件,每行12位数字,前六位是用户名,后六位是相应的密码,要用java创建一个用户登陆界面验证密码是否正确。一点不会java,求完整程序包 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 String account = "111111"; String password = "111111"; Map<String, String> map = new HashMap<String , String>(); String path = "D:\\test.txt"; File file = new File(path); BufferedReader bReader = new BufferedReader(new FileReader(file)); String string = ""; String pc [] = null; String key = ""; String value = ""; while ((string = bReader.readLine()) != null) { pc = string.split(","); key = pc[0]; value = pc[1]; map.put(key, value); } Set<String> keySet = map.keySet(); for (String string2 : keySet) { System.out.println(string2);//账号 System.out.println(map.get(string2));//密码 if (account .equals(string2) && password.equals(map.get(string2))) { System.out.println("账号密码正确"); break; }else { System.out.println("账号密码错误"); } } bReader.close();//txt文本,密码和账号之间用英文逗号分隔 String account = "111111"; String password = "111111"; Map<String, String> map = new HashMap<String , String>(); String path = "D:\\test.txt"; File file = new File(path); BufferedReader bReader = new BufferedReader(new FileReader(file)); String string = ""; String pc [] = null; String key = ""; String value = ""; @SuppressWarnings("unused") boolean result = false; while ((string = bReader.readLine()) != null) { pc = string.split(","); key = pc[0]; value = pc[1]; map.put(key, value); } Set<String> keySet = map.keySet(); for (String string2 : keySet) { System.out.println(string2);//账号 System.out.println(map.get(string2));//密码 if (account .equals(string2) && password.equals(map.get(string2))) { result = true; break; } } if (result = false) { System.out.println("密码错误"); }else { System.out.println("账号密码正确"); } bReader.close();刚那个有点问题,改了一下 关于容器addElement方法的疑问。 怎么把float型转化成String型并保留小数点后的零 一个小的线程问题! 关于ObjectInputStream的问题 提问:jbuilder里哪个组件可以放图片啊? 静态能被序列化?? Servlet的路径问题 初学者问题。 Jbuilder3.0的一个小问题 我又来给分了,清说说Vector的用法和特点,最好有例子。 关于java实现的dbscan算法 通过子窗口怎么改变父窗口的属性
String password = "111111";
Map<String, String> map = new HashMap<String , String>();
String path = "D:\\test.txt";
File file = new File(path);
BufferedReader bReader = new BufferedReader(new FileReader(file));
String string = "";
String pc [] = null;
String key = "";
String value = "";
while ((string = bReader.readLine()) != null) {
pc = string.split(",");
key = pc[0];
value = pc[1];
map.put(key, value);
}
Set<String> keySet = map.keySet();
for (String string2 : keySet) {
System.out.println(string2);//账号
System.out.println(map.get(string2));//密码
if (account .equals(string2) && password.equals(map.get(string2))) {
System.out.println("账号密码正确");
break;
}else {
System.out.println("账号密码错误");
}
}
bReader.close();
//txt文本,密码和账号之间用英文逗号分隔
String password = "111111";
Map<String, String> map = new HashMap<String , String>();
String path = "D:\\test.txt";
File file = new File(path);
BufferedReader bReader = new BufferedReader(new FileReader(file));
String string = "";
String pc [] = null;
String key = "";
String value = "";
@SuppressWarnings("unused")
boolean result = false;
while ((string = bReader.readLine()) != null) {
pc = string.split(",");
key = pc[0];
value = pc[1];
map.put(key, value);
}
Set<String> keySet = map.keySet();
for (String string2 : keySet) {
System.out.println(string2);//账号
System.out.println(map.get(string2));//密码
if (account .equals(string2) && password.equals(map.get(string2))) {
result = true;
break;
}
}
if (result = false) {
System.out.println("密码错误");
}else {
System.out.println("账号密码正确");
}
bReader.close();
刚那个有点问题,改了一下