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.
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