mercredi 25 avril 2018

Read 2 text files in java and compare them irrespective of the order of the lines

I need to know how can I match 2 files a.txt and b.txt using java,

then create a new txt file c.txt which will have the lines which is not in a.txt but in b.txt or vice versa.

The complexity is that, it cannot be done via line by line comparison because

a.txt and b.txt can have same lines but in a different order

eg: a.txt contains a b c

b.txt contains b a c

I don't want the compare to return false because the order is different.

And also I want to know whether it will be a time consuming process if the files have thousand rows in it. Idea is to automate the assert of a test run which generates b.txt file with our expected in a.txt file

Aucun commentaire:

Enregistrer un commentaire