Are there any libraries out there for Java that will accept two strings, and return a string with formatted output as per the *nix diff command?
e.g. feed in
test 1,2,3,4
test 5,6,7,8
test 9,10,11,12
test 13,14,15,16
and
test 1,2,3,4
test 5,6,7,8
test 9,10,11,12,13
test 13,14,15,16
as input, and it would give you
test 1,2,3,4 test 1,2,3,4
test 5,6,7,8 test 5,6,7,8
test 9,10,11,12 | test 9,10,11,12,13
test 13,14,15,16 test 13,14,15,16
Exactly the same as if I had passed the files to diff -y expected actual
I found this question, and it gives some good advice on general libraries for giving you programmatic output, but I'm wanting the straight string results.
I could call diff
directly as a system call, but this particular app will be running on unix and windows and I can't be sure that the environment will actually have diff
available.