java创建用户界面,读取txt文件,进行用户和密码验证

wjmMandy 2017-10-15 09:39:46
数据库系统作业要求先自己建一个txt文件,每行12位数字,前六位是用户名,后六位是相应的密码,要用java创建一个用户登陆界面验证密码是否正确。一点不会java,求完整程序包
...全文
1762 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
傻蛋丫 2020-06-29
  • 打赏
  • 举报
回复
3#比较有问题 ==比较 = 赋值
肥牛熟了熟了 2020-06-29
  • 打赏
  • 举报
回复
亲 我不管输不输密码都直接成功??连比对都没比
是镜花水月 2017-10-16
  • 打赏
  • 举报
回复
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(); 刚那个有点问题,改了一下
是镜花水月 2017-10-16
  • 打赏
  • 举报
回复
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文本,密码和账号之间用英文逗号分隔
qq5588858 2017-10-16
  • 打赏
  • 举报
回复
学习了。非常棒。
李德胜1995 2017-10-16
  • 打赏
  • 举报
回复

62,625

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧