Determing a difference between 2 files

Hey people,
I have two text documents. I basically want to determine whether they're different from eachother.
Also, can I retrieve the actual 'string(s)' that differ the two files? I'm mainly after the first question tho :)

Thanks,
[r.D]
LVL 9
DrWarezzAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
oferzingerConnect With a Mentor Commented:
here is a freeware diff class:
http://www.darwinsys.com/freeware/Diff.java
0
 
DrWarezzAuthor Commented:
Thanks. Could you give me an example of the use of this class please? -- If you've never used it before, then don't worry ;)

ThanQ :)
[r.D]
0
 
oferzingerCommented:
there is a main class:

public static void main(String argstrings[])
      {
            if ( argstrings.length != 2 ) {
              System.err.println("Usage: diff oldfile newfile" );
              System.exit(1);
            }
            Diff d = new Diff();
            d.doDiff(argstrings[0], argstrings[1]);
            return;
      }

you can use the Diff class yourself inside your application:
            
Diff d = new Diff();
d.doDiff(yourStringA, YourStringB;
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
DrWarezzAuthor Commented:
Okay. However, the doDiff method, is of type 'void'. Thus, how do I know what the difference is? :o\

ta
0
 
DrWarezzAuthor Commented:
Ah, I've actually come up with some code that I can use to tell whether two files are different or not.

However, I appreciate your help, so I'll still award you the points :)

ThanQ,
[r.D]
0
 
oferzingerCommented:
it's rather simple from here:

the code includes some showXXX methods like
showsame()
showmove()
etc.
those methods write to std output.
replace the system.out calls to whatever your wish might be.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.