3

Is there a Java lib for line-based diff between multi-line text chunks, that supports before/after context lines, similarly to diff -C in the Unix toolkit?

For example, suppose the first chunk is

a
b
foo
c
d

and the second chunk is

a
b
goo
c
d

then diffing with one line of context should produce something like:

 b
-foo
+goo
 c

Preferably, this should be done using a native Java lib, not calling diff as an external process.

Little Bobby Tables
  • 5,261
  • 2
  • 39
  • 49

1 Answers1

4

Java doesn't have anything to perform diff out of the box. But you can use this java library. This doesn't require you to call a process like diff

shazin
  • 21,379
  • 3
  • 54
  • 71