且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在java的文本文件中搜索和匹配?

更新时间:1970-01-01 07:56:54

你的程序被写回到前面。您需要做的第一件事是从用户那里获取邮政编码。并且不要尝试将其读作 int ,因为文件中的代码都是字符串。获得该字段后,您只需阅读将每个邮政编码与输入的邮政编码进行比较的文件。最后,为什么你在文本中没有双重值时使用 nextDouble



查看你的来源文件格式并仔细考虑如何搜索它以匹配数据。
Your program is written back to front. The first thing you need to do is to get the postcode from the user. And do not try to read it as an int since the codes in your file are all character strings. Once you have that field you just read the file comparing each postcode to the one entered. And lastly why are you using nextDouble when there are no double values in the text?

Look at your source file format and think carefully how you need to search through it to match the data.