[Solved] How to compare and merge two text files?


It’s easy:

  • Read you first file line by line (you can use a Scanner for that).
  • For each line, write it to the output file (you can use a PrintWriter for that).
  • Also store the line in a HashSet.

  • Read your second file line by line.
  • For each line, check if the line is in the HashSet.
  • If it’s not, write it to the output file.

  • Close your files.

0

solved How to compare and merge two text files?