I am working with two big lists of data and I need to efficiently check for matches between the two. This is the scenario:
- Reading from a file line by line (this file has 1 million lines)
- For each line, check within an ArrayList of strings whether it has a match (this ArrayList also has a huge number of elements)
- If a match is found, replace the line from the file with a new value
Any ideas what would be a good way to tackle this problem in terms of efficiency? Obviously looping through that number of records is hopelessly inefficient and process heavy.
Thanks for any help!
UPDATE It's worth noting, I'm not specifically saying I need to use an ArrayList, that is just something I was using for testing. Any suggestions of more efficient Collections would be welcome.