Suppose that I have two String with Java source code of the same file, but different versions. Is there an easy way to compare the two files and highlighting in some way the differences? It would be great if I can use JaxMeJS, because I already use it for parsing the String.
1 Answer
Here is an approach that might work for you: http://www.discursive.com/books/cjcook/reference/manipulate-text-sect-string-diff. It uses the Apache Commons Lang library to provide an edit distance (StringUtils.getLevenshteinDistance) between strings, print out the differences (StringUtils.difference), and the index of the differences (StringUtils.indexOfDifference).