I’m looking for a simple java lib/src to highlight differences between two Strings, case-sensitive. A html output would be great, but I would be happy to get the indexes of the diffs, something like:
diff('abcd','aacd') > [2,2] diff('maniac', 'brainiac') > ['man',brain'] or [0,3] or something like that
The idea is to higlight typos or such in a swing program, since the input shold follow strict conventions.
Apache Commons Lang has a class called StringUtils which has both difference and indexOfDifference which fulfills your needs.
http://commons.apache.org/lang/
Check it out