Diffator 是一个 Java 实现的双向的内容差异 diff 比较库,相似度范围 0.0 ~ 1.0。
示例代码:
String[] wordsA = ...; String[] wordsB = ...; Content ca = new Content(wordsA); Content cb = new Content(wordsB); FileOutputStream fstr = new FileOutputStream("test.html"); SimpleHtmlDiffWriter writer = new SimpleHtmlDiffWriter(fstr); writer.setTitle("My sample diff"); writer.setNewLinesStrategy(NewLinesStrategy.perBlock); ContentComparator.compareStatic(ca, cb, writer);
差异结果: