I doubt your method will work for large files, that cannot fit the memory.

Doing MD5 hash sounds much more reasonable. Even if there's no pre-existing Java solution, you can find pseudo code.