Solved

Determing a difference between 2 files

Posted on 2004-10-10
6
196 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jboss wildfly 10.1 10 240
ejb example issues 3 28
Why doesn't this text field show up on my Applet frame? 2 20
Java class and jar 3 25
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
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 will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

828 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