Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何搜索存储在列表中的句子<;字符串>;在文件中(Java)_Java_Apriori - Fatal编程技术网

如何搜索存储在列表中的句子<;字符串>;在文件中(Java)

如何搜索存储在列表中的句子<;字符串>;在文件中(Java),java,apriori,Java,Apriori,我有两个文件itemsets.txt和combination.txt itemsets.txt包含客户购买物品的详细信息 Butter Bread Jam Bread Jam Cheese Tea Bread Eggs Coffee Tea Coffee Biscuits Biscuits Tea Nutella Cheese Eggs Maggie Coffee Eggs Jam Tea Maggie Tea Biscuits Coffee Bread Biscuits C

我有两个文件itemsets.txt和combination.txt

itemsets.txt包含客户购买物品的详细信息

Butter Bread Jam 
Bread Jam Cheese Tea 
Bread Eggs Coffee 
Tea Coffee Biscuits 
Biscuits Tea 
Nutella Cheese Eggs 
Maggie Coffee 
Eggs Jam Tea 
Maggie Tea 
Biscuits Coffee 
Bread Biscuits Cheese 
Biscuits Nutella 
Coffee Eggs 
Jam Biscuits 
Eggs Bread Biscuits
combination.txt包含支持度大于平均支持度的项目的所有可能组合

 Bread 
 Jam 
 Bread Jam 
 Cheese 
 Bread Cheese 
 Jam Cheese 
 Bread Jam Cheese 
 Tea 
 Bread Tea 
 Jam Tea 
 Bread Jam Tea 
 Cheese Tea 
 Bread Cheese Tea 
 Jam Cheese Tea 
 Bread Jam Cheese Tea 
 Coffee 
 Bread Coffee 
 Jam Coffee 
 Bread Jam Coffee 
 Cheese Coffee 
 Bread Cheese Coffee 
 Jam Cheese Coffee 
 Bread Jam Cheese Coffee 
 Tea Coffee 
 Bread Tea Coffee 
 Jam Tea Coffee 
 Bread Jam Tea Coffee 
 Cheese Tea Coffee 
 Bread Cheese Tea Coffee 
 Jam Cheese Tea Coffee 
 Bread Jam Cheese Tea Coffee 
我想在itemsets.txt文件中搜索组合。如果composition.txt中的字符串存在于itemsets.txt文件中,则该字符串将被复制到新的.txt文件中


如何继续?

读取itemsets.txt的文件内容并将其存储在数组中。现在从combinaton.txt中读取每一行,并在itemsets.txt中查找匹配项。如果匹配,您可以将其存储在新文件中。谷歌的标准文件读写代码应该很容易获得。 例子: 输入:

现在br.readLine()应该为您提供输入。 输出:


希望有帮助。

您能将问题中的图像转换为代码文本吗?@mulliganaire请立即查看
FileReader fr=new FileReader(FILENAME);
BufferedReader br =new BufferedReader(fr);
String str = "Hello";
BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));
writer.write(str);