Solved

Determing a difference between 2 files

Posted on 2004-10-10
6
167 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

708 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

18 Experts available now in Live!

Get 1:1 Help Now