Depending on your exact requirements, the StringUtils class of the Apache Commons Lang component might be helpful, e.g.:
- StringUtils#difference: Compares two Strings, and returns the portion where they differ
- StringUtils#getLevenshteinDistance: Find the Levenshtein distance between two Strings