11

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!

2

2 Answers 2

17

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

Sign up to request clarification or add additional context in comments.

2 Comments

Exactly what I needed: diff, match and patch.
github fork of java-diff-utils: github.com/KengoTODA/java-diff-utils
0

Hi You can run a MR job which can use https://code.google.com/p/google-diff-match-patch/ to do the required job. I dont feel there are any tools out of the box to do your job.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.