Solved

Determing a difference between 2 files

Posted on 2004-10-10
6
181 Views
Last Modified: 2010-03-31
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]
0
Comment
Question by:DrWarezz
  • 3
  • 3
6 Comments
 
LVL 1

Accepted Solution

by:
oferzinger earned 500 total points
ID: 12271729
here is a freeware diff class:
http://www.darwinsys.com/freeware/Diff.java
0
 
LVL 9

Author Comment

by:DrWarezz
ID: 12271740
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
 
LVL 1

Expert Comment

by:oferzinger
ID: 12271762
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Author Comment

by:DrWarezz
ID: 12271771
Okay. However, the doDiff method, is of type 'void'. Thus, how do I know what the difference is? :o\

ta
0
 
LVL 9

Author Comment

by:DrWarezz
ID: 12271782
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
 
LVL 1

Expert Comment

by:oferzinger
ID: 12271793
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
topping3 challenge 14 70
best (free) software to access postgres db (java) 1 33
egit plugin on eclipse 8 41
servlet filter example 37 46
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now