问题描述
我需要一些指导,Java的新手,我在弄清楚我应该编写这个程序的方法时遇到问题。
我有2个文本文件1,其中包含关键字,另一个是包含各种信息的大文本文件。我需要弄清楚如何在大型测试文件中查找关键字文本文件中的单词。例如关键字有(饼,冰,吐司)然后在大文本文件中查找这些单词。用户将选择文本文件和大文本文件。
我尝试过:
我尝试了一段时间循环,但仍然坚持如何将关键字与大文本文件进行比较,使用SAcanner方法我的while循环似乎找不到生成正确的单词所需的单词输出。我做了一个ArrayList()但是输出会将它全部列在一行中,这对我来说似乎没有用,因为大文本文件中的关键字是单行的。
I need some guidance, new to Java, I am having a problem figuring out which way I should code this program.
I have 2 text files 1 with keywords in it and the other is a large text file with all kinds of information. I need to figure out how to look in the large test file for words from the keyword text file. for example keywords has (pie, ice, toast) then look for those words in the large text file. the text file and the large text file will be selected by the user.
What I have tried:
I have tried a while loop but get stuck on how to compare the keyword to the large text file, Using SAcanner method my while loop doesn't seem to find the words it needs to produce the correct output. I did an ArrayList() but the output would list it all in one line and that didn't seem to work for me, because the keywords in the large text file are on single lines.
推荐答案
这篇关于Java阅读2个文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!