Solved

Determing a difference between 2 files

Posted on 2004-10-10
6
189 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 77
Java Server Faces parameter pass? 6 50
type mismatch (Object[] to double[] 4 24
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 33
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 …
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

809 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