I have a column in DB which has a list of all vendors available. The system outputs a file after processing. this text file will contain one vendor name that will be present in the db column. is there a way to find which vendor is present in the text file from the list of vendors available in the db.
As an example, the column values can be,
the text file will have
"MoreTex, a textile company invoice number #384722 5119 09/22/14 Rome limited name dept terms card payment eggplant blah blah blah. total 329 tax Moretex, textile company Address visit www.moretextile.com"
I have to now find if the above text contains any of the vendors in the db. in the above example it matches with "moretex".
should i write something custom or will Lucene or sphinxsearch help here. the vendor list can grow to 100000+ and performance matters.
thanks
答案 0 :(得分:0)
您可以使用org.apache.commons.io.FileUtils获得更好的性能。这是代码
File file = new File("file url");
String content = FileUtils.readFileToString(file);
String[] dbColumn = new String[no. of rows]; //your column values from DB
String colValue = null;
Boolean flag = false;
for(String read : dbColumn)
{
if(readFileToString.contains(read))
{
colVal = read;
flag = true;
}
}
if(flag)
System.out.println(colVal + "exists in file");