有没有Java相关的库可以接受两个字符串,并返回格式化输出的字符串,就像*nix diff命令一样?
例如,输入:
test 1,2,3,4
test 5,6,7,8
test 9,10,11,12
test 13,14,15,16
test 1,2,3,4
test 5,6,7,8
test 9,10,11,12,13
test 13,14,15,16
作为输入,它会给你
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
与直接将文件传递给diff -y expected actual
一样。
我发现了这个问题,它提供了一些关于通用库的建议,可以为您提供编程输出,但我想要纯字符串结果。
我可以直接调用diff
作为系统调用,但这个应用程序将在unix和windows上运行,我不能确定环境是否实际上有可用的diff
。