1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Rep Power

    How Compare two text files and add the contents of one that does not exist in other?

    Hello I am new to Java (and novice) and needed as fast as possible to create a program that does this:
    Read two text files and compare them, what you do not have in the first and second java will add the contents

    missing on the second file,



    I got to the park
    and then decided to kill time



    I Leaves home early
    I got to the park


    Note that both have the phrase "I got to the park" but File2 has the phrase "and then decided to kill time," I want

    the Java
    Copy this entire line or more if you add in the File1 and File2 exactly right after the line that both have equal
    Thus File2 remained at the end as follows:



    I Leaves home early <----------- This does not have the problem of not having File1 for who will be the final file
    will always be the last file in the case here File2.
    I got to the park <------ This sentence both files were then java should ignore it.
    and then decided to kill time <---- That sentence was in file1 not had in File2.


    Please if anyone knows how to do this program tell me it is urgent.

    *** The text files i have are too big for me to review these manually, would take too long.
    Always will be compared only two files. A have lines with phrases that the other lacks.

    To me this program is extremely difficult to do.

    Thank you.
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Eastern Florida
    Rep Power
    As simple as this sounds, it actually can be very difficult. The problem is knowing when to resynch the two files because of false matches. If the files have only unique lines that makes it much easier.

    What have you got for the logic so far?

IMN logo majestic logo threadwatch logo seochat tools logo