Skip to content
Advertisement

Java: How to check that 2 binary files are same?

What is the easiest way to check (in a unit test) whether binary files A and B are equal?

Advertisement

Answer

Are third-party libraries fair game? Guava has Files.equal(File, File). There’s no real reason to bother with hashing if you don’t have to; it can only be less efficient.

Advertisement