Java implementation of Diff