java - org.apache.commons.text.diff 的用途是什么?

标签 java apache-commons

我阅读了org.apache.commons.text.diff的文档。但我仍然不明白类 InsertCommandEditCommandKeepCommandDeleteCommand 可以用来做什么。有人知道它们的全部内容以及如何使用它们吗?

最佳答案

如果比较两个字符串:

A B C E F H (旧)
A C D E G H (新)

那么你的“脚本”是:

Keep   'A'
Delete 'B'
Keep   'C'
Insert 'D'
Keep   'E'
Delete 'F'
Insert 'G'
Keep   'H'

EditCommand 的 javadoc 中所述:

When two objects sequences are compared through the StringsComparator.getScript method, the result is provided has a script containing the commands that progressively transform the first sequence into the second one.

关于java - org.apache.commons.text.diff 的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44834579/

相关文章:

java - Android REST API 连接

java - 如何安装第三方API?

java - 需要帮助来杀死窗口进程,使用 selenium-webdriver

java - 如何在 Eclipse 中划分/分割 Groovy 和 Java 的格式化程序设置?

java - jetty透明代理总是返回403禁止

java - PropertyUtils 性能

java - 如何对两个对象使用集合方法(removeAll() 和 retainAll())。 (对象是父子关系)

java - 如何纠正使用 Java IO 写入文件的无提示失败?

java - 缺少方法 org.apache.commons.io.FileUtils.forceMkdirParent?

java - 如何使用 java 中的反射确定泛型类型的构造函数参数数量?