java - Search if a column value in database exists in a file -


i have column in db has list of vendors available. system outputs file after processing. text file contain 1 vendor name present in db column. there way find vendor present in text file list of vendors available in db.
example, column values can be,

  1. walmart
  2. target
  3. moretex
  4. electra

the text file have

"moretex, 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"

have find if above text contains of vendors in db. in above example matches "moretex".
should write custom or lucene or sphinxsearch here. vendor list can grow 100000+ , performance matters.

you can use org.apache.commons.io.fileutils better performance. here's code

file file = new file("file url"); string content = fileutils.readfiletostring(file); string[] dbcolumn = new string[no. of rows]; //your column values 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"); 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -