文件比较和突出显示 - Java
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3573480/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
File Compare and Highlight - Java
提问by Nitin
I want to compare two text files and want to highlight the differences. Can any one of you help me in doing that thro Java program.
我想比较两个文本文件并突出显示差异。你们中的任何人都可以帮助我完成那个 Java 程序。
Thanks in advance.
提前致谢。
回答by aioobe
Copying one of my answers from a related question:
从相关问题中复制我的答案之一:
I would go for netbeans diff api.
我会选择 netbeans diff api。
From the later url:
从后面的网址:


Although not a visual implementation, you also have a translation of gnu diff in java.
虽然不是可视化实现,但您也可以在 java 中翻译 gnu diff。
回答by Dónal
The google-diff-match-pathlibrary seems to provide the functionality you need. Here's a demoof it in action.
在谷歌的Diff-匹配路径库似乎提供您所需要的功能。这是它的实际演示。
回答by Boris
In Eclipse right click on filename in navigator bar, then select "Compare With".
在 Eclipse 中右键单击导航栏中的文件名,然后选择“比较”。

