tags:

views:

96

answers:

2

Hi,

I'm looking for a diff implementation in Java. I've seen that Python has its own SequenceMatcher (with difflib), which is exactly what I need... in Java.

Is there any portage? Or is there any other class/library that performs the same in Java?

If not, where can I find the source code of that difflib (if free as in speech) to make my own implementation of SequenceMatcher in Java ?

Unfortunately, Apache Commons Lang doesn't help me much.

Thanks!

A: 

What about this one?

(or have a look here)

Andreas_D
+4  A: 

This library seems to be what you're after: google-diff-match-patch.

It has the following main features:

  1. Diff: Compare two blocks of plain text and efficiently return a list of differences.
  2. Match: Given a search string, find its best fuzzy match in a block of plain text. Weighted for both accuracy and location.
  3. Patch: Apply a list of patches onto plain text. Use best-effort to apply patch even when the underlying text doesn't match.

In case you want an alternative, you could also try this: java-diff-utils

KushalP
Exactly what I needed: diff, match and patch.
Frór