Generate formatted diff output in Java

后端 未结 5 833
无人共我
无人共我 2020-12-09 09:53

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

<
5条回答
  •  北海茫月
    2020-12-09 10:20

    java-diff-utils

    The DiffUtils library for computing diffs, applying patches, generationg side-by-side view in Java

    Diff Utils library is an OpenSource library for performing the comparison operations between texts: computing diffs, applying patches, generating unified diffs or parsing them, generating diff output for easy future displaying (like side-by-side view) and so on.

    Main reason to build this library was the lack of easy-to-use libraries with all the usual stuff you need while working with diff files. Originally it was inspired by JRCS library and it's nice design of diff module.

    Main Features

    • computing the difference between two texts.
    • capable to hand more than plain ascci. Arrays or List of any type that implements hashCode() and equals() correctly can be subject to differencing using this library
    • patch and unpatch the text with the given patch
    • parsing the unified diff format
    • producing human-readable differences

提交回复
热议问题